I want to build the binding files for PHP as described here: https://github.com/PDFTron/PDFNetWrappers.
The first steps work fine. I installed cmake and swig and configured cmake via cmake-gui.
But the next step "make" doesn't work. I get an exception:
Linking CXX shared module ../lib/PDFNetPHP.so
Undefined symbols for architecture x86_64:
"__array_init", referenced from:
__wrap_Style_GetColor in PDFNetPHP.cpp.o
__wrap_Word_GetQuad in PDFNetPHP.cpp.o
__wrap_Word_GetGlyphQuad in PDFNetPHP.cpp.o
__wrap_Line_GetQuad in PDFNetPHP.cpp.o
__wrap_BorderStyle_GetDash in PDFNetPHP.cpp.o
__wrap_PDFFunction_EvalFunction in PDFNetPHP.cpp.o
__wrap_Bookmark_GetColor in PDFNetPHP.cpp.o
...
"__convert_to_string", referenced from:
SwigDirector_SignatureHandler::GetName() const in PDFNetPHP.cpp.o
SwigDirector_SignatureHandler::CreateSignature() in PDFNetPHP.cpp.o
__wrap_VectorChar_push in PDFNetPHP.cpp.o
__wrap_VectorChar_set in PDFNetPHP.cpp.o
__wrap_VectorString_push in PDFNetPHP.cpp.o
__wrap_VectorString_set in PDFNetPHP.cpp.o
__wrap_Callback_ErrorReportProc in PDFNetPHP.cpp.o
...
...
I'm using PHP based on Homebrew. The README of PDFNetWrappers says:
"In order to build PHP bindings for MAC OS, we suggest building PHP yourself. When you try to use the bundled PHP interpreter with Mac OS, the CMake code generation process may not be able to locate the PHP header files as well as the PHP library file."
I wonder if my PHP version could be the reason.
But when I add "-v" to "flags.make" to get a more verbose output, I get:
[100%] Building CXX object PDFNetPHP/CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name PDFNetPHP.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -coverage-file /Users/bjoerne/Development/Source/PDFNetWrappers/Build/PDFNetPHP/CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1 -D Clone=CloneHandler -D Eval=EvalFunction -D Function=PDFFunction -D IMPORT -D NDEBUG -D PDFNetPHP_EXPORTS -D Print=PDFPrint -D SWIG -D SWIG_ZEND_ERROR_NORETURN=zend_error -I /usr/local/Cellar/php55/5.5.11/include/php -I /usr/local/Cellar/php55/5.5.11/include/php/main -I /usr/local/Cellar/php55/5.5.11/include/php/TSRM -I /usr/local/Cellar/php55/5.5.11/include/php/Zend -I /usr/local/Cellar/php55/5.5.11/include/php/ext -I /usr/local/Cellar/php55/5.5.11/include/php/ext/date/lib -I /Users/bjoerne/Development/Source/PDFNetWrappers/PDFNetC/Headers -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/bjoerne/Development/Source/PDFNetWrappers/Build/PDFNetPHP -ferror-limit 19 -fmessage-length 160 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o -x c++ /Users/bjoerne/Development/Source/PDFNetWrappers/Build/PDFNetPHP/PDFNetPHP.cpp
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.1.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/php55/5.5.11/include/php
/usr/local/Cellar/php55/5.5.11/include/php/main
/usr/local/Cellar/php55/5.5.11/include/php/TSRM
/usr/local/Cellar/php55/5.5.11/include/php/Zend
/usr/local/Cellar/php55/5.5.11/include/php/ext
/usr/local/Cellar/php55/5.5.11/include/php/ext/date/lib
/Users/bjoerne/Development/Source/PDFNetWrappers/PDFNetC/Headers
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
All the include paths here are correct. I guess that the undefined symbols above are part of Zend libraries. The path /usr/local/Cellar/php55/5.5.11/include/php/Zend is correct.
I use the newest versions of all tools/libraries:
PHP: 5.5.11
XCode: 5.1.1
SWIG: 3.0.0
cmake: 2.8.12.2
Any idea?
This appears to be a problem when linking the PDFNetPHP.so file. Based on the undefined symbols, it sounds like the problem may be that the headers are coming from php 5 but linking is happening against php 4. I believe the linking of PDFNetPHP.so is driven by Build/PDFNetPHP/CMakeFiles/PDFNetPHP.dir/link.txt, so that could be a place to start.
The solution was to modify Build/PDFNetPHP/CMakeFiles/
PDFNetPHP.dir/link.txt and add -Wl,-undefined,dynamic_lookup. This is an argument for ld which is invoked internally by c++.
My file contains now:
/usr/bin/c++ -I/usr/local/Cellar/php55/5.5.11/include/php -I/usr/local/Cellar/php55/5.5.11/include/php/main -I/usr/local/Cellar/php55/5.5.11/include/php/TSRM -I/usr/local/Cellar/php55/5.5.11/include/php/Zend -I/usr/local/Cellar/php55/5.5.11/include/php/ext -I/usr/local/Cellar/php55/5.5.11/include/php/ext/date/lib -bundle -Wl,-headerpad_max_install_names -o …/lib/PDFNetPHP.so CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o …/…/PDFNetC/Lib/libPDFNetC.dylib -Wl,-rpath,/Users/bjoerne/Development/Source/PDFNetWrappers/PDFNetC/Lib -Wl,-undefined,dynamic_lookup
Am Montag, 28. April 2014 19:07:45 UTC+7 schrieb Björn Weinbrenner:
I want to build the binding files for PHP as described here: https://github.com/PDFTron/PDFNetWrappers.
The first steps work fine. I installed cmake and swig and configured cmake via cmake-gui.
But the next step “make” doesn’t work. I get an exception:
Linking CXX shared module …/lib/PDFNetPHP.so
Undefined symbols for architecture x86_64:
“__array_init”, referenced from:
__wrap_Style_GetColor in PDFNetPHP.cpp.o
__wrap_Word_GetQuad in PDFNetPHP.cpp.o
__wrap_Word_GetGlyphQuad in PDFNetPHP.cpp.o
__wrap_Line_GetQuad in PDFNetPHP.cpp.o
__wrap_BorderStyle_GetDash in PDFNetPHP.cpp.o
__wrap_PDFFunction_EvalFunction in PDFNetPHP.cpp.o
__wrap_Bookmark_GetColor in PDFNetPHP.cpp.o
…
“__convert_to_string”, referenced from:
SwigDirector_SignatureHandler::GetName() const in PDFNetPHP.cpp.o
SwigDirector_SignatureHandler::CreateSignature() in PDFNetPHP.cpp.o
__wrap_VectorChar_push in PDFNetPHP.cpp.o
__wrap_VectorChar_set in PDFNetPHP.cpp.o
__wrap_VectorString_push in PDFNetPHP.cpp.o
__wrap_VectorString_set in PDFNetPHP.cpp.o
__wrap_Callback_ErrorReportProc in PDFNetPHP.cpp.o
…
…
I’m using PHP based on Homebrew. The README of PDFNetWrappers says:
“In order to build PHP bindings for MAC OS, we suggest building PHP yourself. When you try to use the bundled PHP interpreter with Mac OS, the CMake code generation process may not be able to locate the PHP header files as well as the PHP library file.”
I wonder if my PHP version could be the reason.
But when I add “-v” to “flags.make” to get a more verbose output, I get:
[100%] Building CXX object PDFNetPHP/CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
“/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang” -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name PDFNetPHP.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -coverage-file /Users/bjoerne/Development/Source/PDFNetWrappers/Build/PDFNetPHP/CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/lib/clang/5.1 -D Clone=CloneHandler -D Eval=EvalFunction -D Function=PDFFunction -D IMPORT -D NDEBUG -D PDFNetPHP_EXPORTS -D Print=PDFPrint -D SWIG -D SWIG_ZEND_ERROR_NORETURN=zend_error -I /usr/local/Cellar/php55/5.5.11/include/php -I /usr/local/Cellar/php55/5.5.11/include/php/main -I /usr/local/Cellar/php55/5.5.11/include/php/TSRM -I /usr/local/Cellar/php55/5.5.11/include/php/Zend -I /usr/local/Cellar/php55/5.5.11/include/php/ext -I /usr/local/Cellar/php55/5.5.11/include/php/ext/date/lib -I /Users/bjoerne/Development/Source/PDFNetWrappers/PDFNetC/Headers -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/bjoerne/Development/Source/PDFNetWrappers/Build/PDFNetPHP -ferror-limit 19 -fmessage-length 160 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o CMakeFiles/PDFNetPHP.dir/PDFNetPHP.cpp.o -x c++ /Users/bjoerne/Development/Source/PDFNetWrappers/Build/PDFNetPHP/PDFNetPHP.cpp
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.1.0
ignoring nonexistent directory “/usr/include/c++/v1”
#include “…” search starts here:
#include <…> search starts here:
/usr/local/Cellar/php55/5.5.11/include/php
/usr/local/Cellar/php55/5.5.11/include/php/main
/usr/local/Cellar/php55/5.5.11/include/php/TSRM
/usr/local/Cellar/php55/5.5.11/include/php/Zend
/usr/local/Cellar/php55/5.5.11/include/php/ext
/usr/local/Cellar/php55/5.5.11/include/php/ext/date/lib
/Users/bjoerne/Development/Source/PDFNetWrappers/PDFNetC/Headers
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/lib/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/lib/clang/5.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
All the include paths here are correct. I guess that the undefined symbols above are part of Zend libraries. The path /usr/local/Cellar/php55/5.5.11/include/php/Zend is correct.
I use the newest versions of all tools/libraries:
PHP: 5.5.11
XCode: 5.1.1
SWIG: 3.0.0
cmake: 2.8.12.2
Any idea?