Dealing with linker errors: ld: symbol(s) not found for architecture arm64

I have been working on a PHP compile for my Apple M1 and have been dealing with dependency snags related to the arm64 architecture. I solved some similar linking errors related to openssl, but I still hit errors linking to the oniguruma libraries. I have compiled with various configurations, and from what I can tell, the resulting libraries are arm64 compatible. A call to objdump -a /usr/local/oniguruma/lib/libonig.a shows output similar to:

/usr/local/oniguruma/lib/libonig.a(cp1251.o):	file format mach-o arm64

rw-r--r-- 501/20   8828 Fri Jan 14 11:33:41 2022 cp1251.o

/usr/local/oniguruma/lib/libonig.a(onig_init.o):	file format mach-o arm64

rw-r--r-- 501/20   3772 Fri Jan 14 11:33:41 2022 onig_init.o

My env has the following: LDFLAGS="-L/usr/local/oniguruma/lib -L/usr/local/openssl/lib $LDFLAG" and I have verified the call to clang specifies the correct directory for the library.

I feel like I am missing something obvious, and I have been at this for a while now. Do I need to specify the library location in a different way? Is there anything else I need to check to ensure that the library is indeed compatible with the project?

Thanks.
Leonard Smith

Can you post the full error and command line invocation?

@tobiashieta Thanks for getting back to me. As I was collecting the error output, etc. to post here, I reran the configure script and the make call and went on to do something else. Came back and the darn thing worked!! I shutdown my system last night to install a new UPS, so something in my shell environment must have been dirty. It’s my only guess.

In case anyone comes around looking, though, here is the configure call I used for PHP 8.1.1:

env LDFLAGS="-L/usr/local/oniguruma/lib -L/usr/local/openssl/lib $LDFLAG" PKG_CONFIG_PATH="/usr/local/oniguruma/lib/pkgconfig" ./configure \
  --prefix=/usr/local/mac-dev-env/php-8.1.1 \
  --with-config-file-path=/usr/local/mac-dev-env/php-8.1.1/etc \
  --enable-bcmath \
  --enable-mbregex \
  --enable-mbstring \
  --enable-sockets \
  --with-bz2=/usr/local/bzip2 \
  --with-curl \
  --with-mysqli \
  --with-pear \
  --with-pdo-mysql \
  --with-xsl \
  --with-zlib \
  --with-iconv=/usr/local/libiconv \
  --without-pcre-jit \
  CFLAGS="-I/usr/local/openssl/include -I/usr/local/oniguruma/include $CFLAGS"

I am using openssl 1.1.1m and oniguruma 6.9.5_rev1 both of which I compiled locally.

1 Like