[php-src] Issue #8533: embed SAPI: unable to link on Mac
| From: | dunglas | Date: | Wed, 11 May 2022 10:20:36 +0000 |
| Subject: | [php-src] Issue #8533: embed SAPI: unable to link on Mac | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241458@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8533
Author: dunglas
### Description
I compiled PHP with the following options:
```
./configure \
--enable-zts \
--enable-embed=dylib \
--with-iconv=/opt/homebrew/opt/libiconv/ \
--without-pcre-jit \
--enable-debug
```
When trying to link
libphp.so on Mac with the following flags:
```
CFLAGS: -Wall -Wno-unused-variable
CFLAGS: -I/usr/local/include/php -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM
-I/usr/local/include/php/main
LDFLAGS: -L/usr/local/lib -lphp
```
I get this error:
```
link: running clang failed: exit status 1
ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file
'/usr/local/lib/libphp.so' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
This looks related to this StackOverflow answer: https://stackoverflow.com/a/32765319/1352334
On Mac, it looks lile the -bundle flag passed to ld must be replaced by
-dynamiclib.
### PHP Version
PHP 8.1.5
### Operating System
Mac OS X