Open yarcowang opened 8 years ago
hi, I changed the default compiler to the g++-6 (installed by brew )
After upgrade to g++-6, then do CXX=g++-6 make
, i got:
...
g++-6 -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings -g `php-config --includes` -fpic -o shared/zend/zval.o zend/zval.cpp
/usr/local/bin/php-config: line 43: /usr/local/Library/ENV/4.3/sed: No such file or directory
g++-6 -shared -g `php-config --ldflags` -Wl,-soname,libphpcpp.so.2.0 -o libphpcpp.so.2.0.0 shared/common/modifiers.o shared/common/streambuf.o shared/zend/base.o shared/zend/callable.o shared/zend/classbase.o shared/zend/classimpl.o shared/zend/constant.o shared/zend/constantfuncs.o shared/zend/eval.o shared/zend/exception_handler.o shared/zend/exists.o shared/zend/extension.o shared/zend/extensionimpl.o shared/zend/fatalerror.o shared/zend/file.o shared/zend/function.o shared/zend/functor.o shared/zend/global.o shared/zend/globals.o shared/zend/hashmember.o shared/zend/ini.o shared/zend/inivalue.o shared/zend/iteratorimpl.o shared/zend/members.o shared/zend/module.o shared/zend/namespace.o shared/zend/object.o shared/zend/sapi.o shared/zend/script.o shared/zend/streambuf.o shared/zend/streams.o shared/zend/super.o shared/zend/value.o shared/zend/valueiterator.o shared/zend/zendcallable.o shared/zend/zval.o
/usr/local/bin/php-config: line 43: /usr/local/Library/ENV/4.3/sed: No such file or directory
ld: unknown option: -soname
collect2: error: ld returned 1 exit status
make: *** [libphpcpp.so.2.0.0] Error 1
Change -soname to -install_name
After change lineno 179 (makefile) from
${LINKER} ${PHP_LINKER_FLAGS} -Wl,-soname,libphpcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
To
${LINKER} ${PHP_LINKER_FLAGS} -Wl,-install_name,libphpcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
Then i got this:
Php::StreamBuf::sync() in streambuf.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [libphpcpp.so.2.0.0] Error 1
Maybe i shouldn't compile it under mac?
you need add -undefined dynamic_lookup to LINKER_FLAGS
@willianszwy Yes, finally make it done.
Here are the steps for those who want to compile it under mac.
gcc
version of the c++ compiler g++-6
(not the apple one, clang++)-undefined dynamic_lookup
config like the document said, so the LINKER_FLAGS becomes:
LINKER_FLAGS = -shared -undefined dynamic_lookup
-soname
to install_name
, so the that line becomes:
${LINKER} ${PHP_LINKER_FLAGS} -Wl,-install_name,libphpcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
CXX=g++-6 make
Forgot to say thank you, @willianszwy
mac version 10.10.5 php installed from homebrew: