I have upgraded a Mac to macOS 10.12.0 Sierra, and am trying to upgrade PHP to version 7.0.9, but ‘make test’ fails with:
Undefined symbols for architecture x86_64: "_libiconv", referenced from: _zif_iconv_substr in iconv.o _zif_iconv_mime_encode in iconv.o _php_iconv_string in iconv.o __php_iconv_strlen in iconv.o __php_iconv_strpos in iconv.o __php_iconv_appendl in iconv.o _php_iconv_stream_filter_append_bucket in iconv.o ... "_libiconv_close", referenced from: _zif_iconv_substr in iconv.o _zif_iconv_mime_encode in iconv.o _php_iconv_string in iconv.o __php_iconv_strlen in iconv.o __php_iconv_strpos in iconv.o __php_iconv_mime_decode in iconv.o _php_iconv_stream_filter_factory_create in iconv.o ... "_libiconv_open", referenced from: _zif_iconv_substr in iconv.o _zif_iconv_mime_encode in iconv.o _php_iconv_string in iconv.o __php_iconv_strlen in iconv.o __php_iconv_strpos in iconv.o __php_iconv_mime_decode in iconv.o _php_iconv_stream_filter_factory_create in iconv.o ... ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libs/libphp7.bundle] Error 1
I compiled it with:
./configure --prefix=/usr/local/php5 --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc --with-config-file-path=/etc --with-zlib --with-zlib-dir=/usr --with-openssl=/usr/local --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-apxs2=/usr/local/apache2/bin/apxs --enable-zip --with-curl
and have tried adding different ‘–with-iconv-dir=’ options but always get the same undefined symbols error.
I have downloaded and compiled libiconv to no avail. Even configured the compile with:
CFLAGS=’-arch x86_64′ CCFLAGS=’-arch x86_64′ CXXFLAGS=’-arch x86_64′ ./configure
but that made no difference. Any suggestions?
Any help would be much appreciated.
This might solve the problem
vim Makefile find EXTRA_LDFALGS and EXTRA_LDFLAGS_PROGRAMS remove L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib
- brew install libiconv
(libiconv will install in /usr/local/opt/libiconv/)
- find EXTRA_LIBS variable in MakeFile.
Here is the reason:
- Mac os has its own
dir/usr/lib/libiconv.dylib, which do not
_libiconv _libiconv_close . founctions. Update to a new libiconv version and reference to it will solve the case
I’ll teach you. That’s caused due to broken symbol during your php source code compilation process.
Since OS X uses llvm toolchain based clang, and the php original source code is based on GNU libraries in which it’s compatible for gcc only rather than clang you’re already familiar with.
Their architectures seem to be incompatible somehow.
In one word, original libiconv source code was definitely not compatible with OS X.
Installing by the command in OS X resolved the issues:
brew install libiconv.
[email protected] ~ % brew install libiconv
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
==> Updated Formulae
ammonite-repl contentful-cli gwt libwebsockets salt
angular-cli detekt homeassistant-cli mapserver stress-ng
ask-cli ethereum katago php topgrade
bazel exploitdb lerna [email protected]
borgmatic fastlane libdeflate [email protected]
conan gatsby-cli libmypaint pidgin
Warning: libiconv 1.16 is already installed and up-to-date
To reinstall 1.16, run
brew reinstall libiconv
Because it’ll be installing OS X-compatible library with complete x86-64bit symbol.
I had same issue yesterday when I was about to practicing php 5 earlier version. I compiled successfully on OS X – the latest version “Mac OS X 10.15.4, Catalina.”
I’m advising you that you do not use the latest version of every development toolchain as always. In a way, you would be conflicting less, it directly means less time consuming when you’re doing more important tasks.
and you even need to edit Makefile before you command “make” to compile on OS X.
Mac developer often uses “nano command line tool instead of vi”:
and then find EXTRA_LIBS environment variable change -liconv to /usr/local/opt/libiconv/lib/libiconv.dylib – where it is location for Mac OS X compatible library is installed by homebrew.
Because -liconv’s default path is somewhere else: /usr/lib/ – which the incompatible with broken architecture symbol resides.
So where can you see the diffs between linux kernel system and OS X system:
.so file exension for linux one and dylib for mac os one?
The names imply their compiling architecture and the structure inside
are a little bit different.
I added more reasonable details for you beside the answer snippet above to explain clearly.
So let me explaining at one point:
It is the issue of broken architecture symbols during your GNU source
code compilation which is not compatible to OS X Unix system
Because OS X is more BSD system alike than is linux kernel alike.
- I’m developing hobbyist. so I don’t even know all. you’ll need to learn everyday also. good luck.
I would like to recommend you read the book “The Software
Craftsman – written by Sandro Mancuso.” It is more suitable method(not a tool anyway) for
developing and debugging spaces I personally can think of. Someone else denies that