Im trying to build an application on the mac (host) for the raspberry pi (target) that will use zeromq. I can write a simeple program that uses pthread and it runs perfectly. When I enable -lzmq, linking fails on all of the pthread calls in zeromq. Why is the version of the missing glibc different at each failure? The libc is installed and reports the following version:
ii libc-bin 2.36-9+rpt2+deb12u9 arm64 GNU C Library: Binariesii libc-dev-bin 2.36-9+rpt2+deb12u9 arm64 GNU C Library: Development binariesii libc-devtools 2.36-9+rpt2+deb12u9 arm64 GNU C Library: Development toolsii libc-l10n 2.36-9+rpt2+deb12u9 all GNU C Library: localization files
The error I receive when linking
/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `__libc_single_threaded@GLIBC_2.32'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_sigmask@GLIBC_2.32'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_join@GLIBC_2.34'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_setname_np@GLIBC_2.34'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_mutex_trylock@GLIBC_2.34'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `stat@GLIBC_2.33'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_mutexattr_settype@GLIBC_2.34'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_create@GLIBC_2.34'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_cond_clockwait@GLIBC_2.34'/Users/rich/workspace/rpi/sysroot/usr/local/lib/libzmq.so: undefined reference to `pthread_mutexattr_destroy@GLIBC_2.34'
Setup:
- the zmq and czmq libs are built on the raspbery pi
- the /usr/local and /lib directories where copied to the macos
- compiler is aarch64-unknown-linux-gnu version 13.3.0 available from homebrew.
- built with this makefile
Makefile
######################################## target: proto#######################################TARGET = protomq######################################## options#######################################GCC_PATH = CFLAGS = PREFIX = OPT = C_DEFS = CFLAGS = ifeq ($(DEBUG), 1)OPT += -Og -g3C_DEFS += -DDEBUG$(info building WITH debugging information)else OPT += -Og -g3$(info building WITHOUT debugging information)endififeq ($(VERBOSE), 1)OPT += -v$(info verbose building)endifGCC_PATH += /opt/homebrew/Cellar/aarch64-unknown-linux-gnu/13.3.0/bin/PREFIX += aarch64-unknown-linux-gnu-######################################## binaries#######################################CC = $(PREFIX)gccCXX = $(PREFIX)g++AS = $(PREFIX)gcc -x assembler-with-cppCP = $(PREFIX)objcopySZ = $(PREFIX)sizeHEX = $(CP) -O ihexBIN = $(CP) -O binary -S######################################## paths#######################################BUILD_DIR = buildSYSROOT =/Users/rich/workspace/rpi/sysroot######################################## compiler flags#######################################CFLAGS += $(OPT) $(C_DEFS) -Wall -Wextra -std=c11 --sysroot=$(SYSROOT) -v -pipe -mlittle-endian -march=armv8-aLDLIBS += -L$(SYSROOT)/lib -L$(SYSROOT)/usr/local/libLDFLAGS += -lc -lm -pthread -lrt -ldl -pthread -lzmq####################################### source######################################'C_SOURCES = \$(wildcard *.c) \middleware/tlog/tlog.c \C_INCLUDES = \-I. \-Imiddleware/tlog/ \-I$(SYSROOT)/usr/include \-I$(SYSROOT)/usr/include/aarch64-linux-gnu \-I$(SYSROOT)/usr/local/include \C_DEFS += \# Create the build directory if it doesn't exist$(BUILD_DIR): mkdir -p $(BUILD_DIR) # Create the necessary subdirectories in the build directory$(BUILD_DIR)/%.o: %.c mkdir -p $(dir $@) $(CC) -c $(CFLAGS) $(C_INCLUDES) -c $< -o $@# Compile the C source files into object files in the build directory$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR) $(CC) -c $(CFLAGS) $(C_INCLUDES) -c $< -o $@# List of object filesC_OBJECTS = $(C_SOURCES:%.c=$(BUILD_DIR)/%.o)CPP_OBJECTS = $(CPP_SOURCES:%.cpp=$(BUILD_DIR)/%.o)OBJECTS = $(C_OBJECTS)####################################### build######################################buildnumber: buildnumber.h.stampbuildnumber.h.stamp: $(C_SOURCES) buildnumber --file buildnumber.h touch buildnumber.h.stampall: $(TARGET) $(TARGET): $(OBJECTS) buildnumber.h.stamp $(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LDLIBS)clean: rm -rf $(TARGET) $(BUILD_DIR)/*.o buildnumber.h.stamp
tried varrious link flags but nothing helped