Linking xerces static library for Mac OS X - macos

I'm trying to link xerces as a static library, but I have some problems...
Undefined symbols for architecture x86_64:
"_CFRelease", referenced from:
xercesc_3_1::MacOSUnicodeConverter::upperCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
xercesc_3_1::MacOSUnicodeConverter::lowerCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
"_CFStringCreateMutableWithExternalCharactersNoCopy", referenced from:
xercesc_3_1::MacOSUnicodeConverter::upperCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
xercesc_3_1::MacOSUnicodeConverter::lowerCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
"_CFStringLowercase", referenced from:
xercesc_3_1::MacOSUnicodeConverter::lowerCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
"_CFStringUppercase", referenced from:
xercesc_3_1::MacOSUnicodeConverter::upperCase(unsigned short*) in libxerces-c.a(MacOSUnicodeConverter.o)
"_CreateTextEncoding", referenced from:
xercesc_3_1::MacOSUnicodeConverter::discoverLCPEncoding() in libxerces-c.a(MacOSUnicodeConverter.o)
xercesc_3_1::MacOSUnicodeConverter::makeNewXMLTranscoder(unsigned short const*, xercesc_3_1::XMLTransService::Codes&, unsigned long, unsigned int, xercesc_3_1::MemoryManager*) in libxerces-c.a(MacOSUnicodeConverter.o)
...
I've tried to run configure with different options, but all attempts were useless.
Has anyone had the same problem?

I ran into this issue when building xalan. I fixed it by passing -framework CoreServices -framework CoreFoundation -lcurl to the linker.
Line 76 of xalan's Makefile.incl:
XERCES_LIB = -L$(XERCESCROOT)/lib -lxerces-c -framework CoreServices -framework CoreFoundation -lcurl

Related

Linking error with vrpn and libusb in Mac OS X

I'm getting the following error when I try to compile vrpn 7.33 on a Mac. It says that libusb was compiled for a different architecture than vrpn is being compiled:
Linking CXX executable client_and_server
ld: warning: ignoring file /usr/local/lib/libusb-1.0.dylib, file was built for i386 which is not the architecture being linked (x86_64): /usr/local/lib/libusb-1.0.dylib
Undefined symbols for architecture x86_64:
"_libusb_claim_interface", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_close", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_exit", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_init", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_open_device_with_vid_pid", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.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[2]: *** [server_src/client_and_server] Error 1
make[1]: *** [server_src/CMakeFiles/client_and_server.dir/all] Error 2
make: *** [all] Error 2
But when I recompile libusb changing the architecture to x86_64 I start getting the following error:
Linking CXX executable client_and_server
ld: warning: ignoring file /usr/local/lib/libusb-1.0.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libusb-1.0.dylib
Undefined symbols for architecture i386:
"_libusb_claim_interface", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_close", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_exit", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::~vrpn_Tracker_USB() in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_init", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
"_libusb_open_device_with_vid_pid", referenced from:
vrpn_Tracker_USB::vrpn_Tracker_USB(char const*, vrpn_Connection*, unsigned short, unsigned short, long) in libvrpnserver.a(vrpn_Tracker.C.o)
vrpn_Tracker_USB::mainloop() in libvrpnserver.a(vrpn_Tracker.C.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [server_src/client_and_server] Error 1
make[1]: *** [server_src/CMakeFiles/client_and_server.dir/all] Error 2
make: *** [all] Error 2
Notice how now the linker is searching for the original i386 architecture.
Why does vrpn complain in both cases?
vrpn is being compiled for multiple architectures at the same time. That is why a compiling libusb for a single architecture doesn't work.
The solution is to compile libusbfor the two architecutres at the same time using the following sequence of commands:
./configure
make CFLAGS="-arch x86_64 -arch i386" LDFLAGS="-arch x86_64 -arch i386"
sudo make install
If you want more information about compiling Universal binaries in Mac OS X check this link:
Compiling Your Code in OS X (Compiling for Multiple CPU Architectures)

Metaio App in Unity3D not building from XCode

I am trying to build an augmented reality app built in Unity3d using the Metaio Unity SDK. The app uses a CAD model as a target upon which it augments stuff. It looks for something like the reference CAD model in the real world and then latches onto that. In XCode, I add, from Libraries, the metaiosdk file (not metaiosdk.framework) to the Link Binaries to Libraries section. I also add the libxml2.dylib framework. When I build, I fail with tons of errors. The errors all claim that "directory not found for option '-L/..." for Metaio framework. When I search "search paths" in Build Settings and delete them all (per this SO answer), I go down to only one error, saying that there is no Metaio Framework. When I add the whole SDK folder to the project and redo the previous steps, including having to delete search paths for libraries and headers again, I then get an error saying that -liPhone-lib library was not found. I reimport that library, following the instructions from this Metaio Helpdesk post, at which point I then re-delete the search paths for libraries and headers (or else I get about 30 errors again). Then when I build I get only one error, saying that "'Unity/GlesHelper.h' was not found." I am at a loss, as Google turns up no results for "GlesHelper.h" (in this context). What am I doing wrong? Does the SDK need to be inside the Unity project and the Unity Project inside the folder of the XCode project? Is it the opposite way around? Do I need to import the example scenes and not just the scene I am using? Thank you for the help!
EDIT: Here is an example of the erros I get before deleting the search Library Paths in Build Settings:
d: warning: directory not found for option
'-L"/Users/capture/Desktop/iMacXC2/Libraries"' Undefined symbols for
architecture armv7:
"_CIDetectorAccuracy", referenced from:
__ZNWwTeFvdBdVkDNRXNPUfEgifAKsRnrNYugVMtgpHhPUMqd in metaiosdk(xhvKRhZZTIhPZZYtqieHqfH) "_OBJC_CLASS_$_CIDetector",
referenced from:
objc-class-ref in metaiosdk(xhvKRhZZTIhPZZYtqieHqfH) "_kSecReturnRef", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_CIDetectorAccuracyLow",
referenced from:
__ZNWwTeFvdBdVkDNRXNPUfEgifAKsRnrNYugVMtgpHhPUMqd in metaiosdk(xhvKRhZZTIhPZZYtqieHqfH) "_kSecMatchPolicy", referenced
from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_kSecMatchLimitOne",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_kSecMatchLimit", referenced
from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_kSecClass", referenced
from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLWrite", referenced from:
_darwinssl_send in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLGetBufferedReadSize", referenced from:
_Curl_darwinssl_data_pending in metaiosdk(libcurl_la-curl_darwinssl.o) "_kSecClassIdentity",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLClose", referenced from:
_Curl_darwinssl_close in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetSessionOption",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o)
"_SSLGetNumberSupportedCiphers", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLCreateContext",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetProtocolVersionMax",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SecItemCopyMatching",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o)
"_SSLGetNegotiatedProtocolVersion", referenced from:
_darwinssl_connect_step2 in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetProtocolVersionMin",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLGetSessionState",
referenced from:
_Curl_darwinssl_check_cxn in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetEnabledCiphers",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SecPolicyCreateSSL",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o)
"_SecIdentityCopyCertificate", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetPeerID", referenced
from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLGetNegotiatedCipher",
referenced from:
_darwinssl_connect_step2 in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetPeerDomainName",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLRead", referenced from:
_darwinssl_recv in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetIOFuncs", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLHandshake", referenced
from:
_darwinssl_connect_step2 in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLCopyPeerTrust",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLGetSupportedCiphers",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o)
"_SecCertificateCopySubjectSummary", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_SSLSetConnection",
referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) "_CIDetectorTypeFace",
referenced from:
__ZNWwTeFvdBdVkDNRXNPUfEgifAKsRnrNYugVMtgpHhPUMqd in metaiosdk(xhvKRhZZTIhPZZYtqieHqfH) "_SSLSetCertificate", referenced
from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o)
"_SecTrustGetCertificateCount", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o)
"_SecTrustGetCertificateAtIndex", referenced from:
_darwinssl_connect_common in metaiosdk(libcurl_la-curl_darwinssl.o) ld: symbol(s) not found for
architecture armv7 clang: error: linker command failed with exit code
1 (use -v to see invocation)
And then after I delete the Library Search Paths, I get this:
Ld
/Users/capture/Library/Developer/Xcode/DerivedData/Unity-iPhone-glogufgfblmcyzasljopkkqcjtso/Build/Products/iMac.app/iMac
normal armv7
cd /Users/capture/Desktop/iMacXC2
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
-L/Users/capture/Library/Developer/Xcode/DerivedData/Unity-iPhone-glogufgfblmcyzasljopkkqcjtso/Build/Products
-F/Users/capture/Library/Developer/Xcode/DerivedData/Unity-iPhone-glogufgfblmcyzasljopkkqcjtso/Build/Products
-filelist /Users/capture/Library/Developer/Xcode/DerivedData/Unity-iPhone-glogufgfblmcyzasljopkkqcjtso/Build/Intermediates/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/armv7/iMac.LinkFileList
-dead_strip -weak_framework CoreMotion -weak-lSystem -stdlib=libstdc++ -fobjc-link-runtime -miphoneos-version-min=7.1 /Users/capture/Desktop/iMacXC2/Libraries/metaiosdk -lxml2 -framework
Foundation -framework UIKit -framework OpenGLES -framework QuartzCore
-framework OpenAL -liconv.2 -liPhone-lib -framework AudioToolbox -framework CFNetwork -framework MediaPlayer -framework CoreLocation -framework SystemConfiguration -weak_framework iAd -framework CoreMedia -framework CoreVideo -weak_framework AVFoundation -framework
CoreGraphics -weak_framework CoreMotion -weak_framework GameKit
-Xlinker -dependency_info -Xlinker /Users/capture/Library/Developer/Xcode/DerivedData/Unity-iPhone-glogufgfblmcyzasljopkkqcjtso/Build/Intermediates/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/armv7/iMac_dependency_info.dat
-o /Users/capture/Library/Developer/Xcode/DerivedData/Unity-iPhone-glogufgfblmcyzasljopkkqcjtso/Build/Products/iMac.app/iMac
ld: library not found for -liPhone-lib clang: error: linker command
failed with exit code 1 (use -v to see invocation)
And after I re-import the missing library, I just continue on that pattern of get errors for Library Search Paths, have to reimport Library, repeat, over and over, until reaching the above image where I need Unity/GlesHelper.h, at which point I am at a loss.
You are right, you do need Unity Pro, but it looks like you missed some steps from the Metaio Getting Started with Unity page. You need to drag in the metaioSDK as you have done, but you also need to add frameworks for:
libc++.dylib
libxml2.2.dylib (you did this one)
Security.framework
CoreImage.framework (SDK 5.5 and newer)
Metaio requires a Unity pro license because it is a plugin, and it will fail to launch without said license. I was attempting to compile without a license. (Lesson learned)

Linking error - Undefined symbols for architecture x86_64 on OSX

The following is returned when trying to compile part of a project under OSX:
gcc -g -pipe -L/Projects/export buf_test.o buf.o -framework CoreFoundation -o buf_test
Undefined symbols for architecture x86_64:
"___assert_rtn", referenced from:
_init in buf.o
_get in buf.o
_put in buf.o
"___sprintf_chk", referenced from:
_test in buf_test.o
"___strcpy_chk", referenced from:
_test_data_copy in buf_test.o
___inline_strcpy_chk in buf_test.o
"_exit", referenced from:
start in crt1.10.6.o
"_printf", referenced from:
_test in buf_test.o
"_puts", referenced from:
_test in buf_test.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Help would be much appreciated!
Turns out it was a library naming conflict with the standard libraries -- I had a library called libSystem.a in /Projects/export which was masking libSystem.dylib from being found.

Using Crypto++ with clang

I'm attempting to get the following Crypto++ (C++ Class Library of Cryptographic Schemes) example to work on a iMac using clang++.
Example
SHA256 hash;
byte digest[ SHA256::DIGESTSIZE ];
hash.CalculateDigest( digest, (byte*) &value[ 0 ], value.size( ) );
HexEncoder encoder;
string result = String::empty;
encoder.Attach( new StringSink( result ) );
encoder.Put( digest, sizeof( digest ) );
encoder.MessageEnd( );
Build command
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.7.4 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name checksum_impl.cpp -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 123.2.1 -v -resource-dir /usr/bin/../lib/clang/2.1 -D framework_EXPORTS -I /Users/Ben/Dropbox/appon/build/../source -nostdinc++ -cxx-isystem /usr/include/c++/v1 -Wall -Wextra -Weffc++ -pedantic -std=c++0x -fdeprecated-macro -ferror-limit 19 -fmessage-length 175 -stack-protector 1 -fblocks -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o CMakeFiles/framework.dir/Users/Ben/Dropbox/source/example.cpp.o -x c++ /Users/Ben/Dropbox/source/example.cpp
clang -cc1 version 2.1 based upon llvm 3.0svn hosted on x86_64-apple-darwin11.4.0
#include "..." search starts here:
#include <...> search starts here:
/Users/Ben/Dropbox/build/../source
/usr/include/c++/v1
/usr/local/include
/usr/bin/../lib/clang/2.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
Linker output
clang: warning: argument unused during compilation: '-std=c++0x'
Undefined symbols for architecture x86_64:
"CryptoPP::Filter::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) const", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::BufferedTransformation::ChannelCreatePutSpace(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long&)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::BufferedTransformation::ChannelPut2(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char const*, unsigned long, int, bool)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::BufferedTransformation::ChannelPutModifiable2(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char*, unsigned long, int, bool)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::BufferedTransformation::ChannelFlush(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, int, bool)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::BufferedTransformation::ChannelMessageSeriesEnd(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.o
"CryptoPP::BufferedTransformation::SetRetrievalChannel(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
vtable for CryptoPP::SimpleProxyFilter in checksum_impl.cpp.o
vtable for CryptoPP::Bufferless<CryptoPP::Filter> in checksum_impl.cpp.o
vtable for CryptoPP::Unflushable<CryptoPP::Filter> in checksum_impl.cpp.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: *** [all] Error 2
I'm using the latest development version of Crypto++ 5.6.2 as the previous version 5.6.1 fails to build with clang++. However i'm encountering build issues stating that i have missing symbols for x86_64 architecture.
Any hints would be greatly appreciated.
Crypto++ 5.6.2 successfully build on LLVM version 6.1.0 (clang-602.0.53) with make options:
CXXFLAGS="-std=c++11 -stdlib=libstdc++ -DCRYPTOPP_DISABLE_ASM -Wno-c++11-narrowing"
accordingly this script: https://github.com/mapnik/mapnik-packaging/blob/master/osx/scripts/build_cryptopp.sh
-stdlib=libstdc++ need for MacOSX since Mavericks, see: When is it necessary to use use the flag -stdlib=libstdc++?
you need to link to the library that provides those symbols, which should be libcryptopp.so, using-lcryptopp in the compiler command
Looking at your "build command" (which is not the command you're running, it's the output of the command you're running, it would be a lot easier to read if you showed the actual command) it seems you are compiling a .cpp file into a .o file, but getting a linker error, which is strange as producing a .o file is usualy the step before linking. What step are you trying to do? Maybe you also need to add -c so it only compiles and doesn't try to link. You will still need -lcryptopp when linking.
In addition to Jonathon's answer because this is a fairly prevalent problem when -lcryptopp is specified...
Undefined symbols for architecture x86_64. CryptoPP::Filter::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)"...
The __1 indicates you are using the LLVM C++ runtime (libc++). Somewhere, you are probably mixing and matching with the GNU C++ runtime (libstdc++). The GNU C++ runtime (libstdc++) lacks the __1 decoration on its symbols.
You should go through the project and all pre-built libraries, and ensure they are using one or the other. For each, you should use CXXFLAGS of either (1) -stdlib=libc++ (LLVM), or (2) -stdlib=libstdc++ (GNU).
Be aware that IDEs like Xcode may use a different -stdlib=... setting than Crypto++. In this case, have Xcode match Crypto++, or rebuild the Crypto++ library to match Xcode.
If Xcode is using LLVM's libc++ and you have to rebuild Crypto++, then open the GNUmakefile and rework this section (around line 90):
ifeq ($(UNAME),Darwin)
AR = libtool
ARFLAGS = -static -o
CXX = c++
IS_GCC2 = $(shell $(CXX) -v 2>&1 | $(EGREP) -c gcc-932)
ifeq ($(IS_GCC2),1)
CXXFLAGS += -fno-coalesce-templates -fno-coalesce-static-vtables
LDLIBS += -lstdc++
LDFLAGS += -flat_namespace -undefined suppress -m
endif
endif
If you want to use LLVM's libc++, then remove:
# GNU C++ Runtime
LDLIBS += -lstdc++
And add:
# LLVM C++ Runtime
CXXFLAGS += -stdlib=libc++
For completeness, if you want to use GNU's runtime, then remove the LDLIBS += -lstdc++ and add CXXFLAGS += -stdlib=libstdc++.
You can also change CXX = c++ to CXX ?= c++ so the makefile will use c++ if its not specified in the environment or command line.
If interested, the __1 is an inline namespace used for versioning. See What are inline namespaces for? and Where does the __1 symbol come from when using LLVM's libc++?.
This issue was relating to Crypto++ not having been ported over to llvm-clang++. The supported compilers are listed on Platforms; supported compilers for previous releases are listed on Compiling.
My solution was to instead use GCrypt.
Sorry I can't supply anymore details on the cause of the failure.

Linker error with libpng under MacOSX

I'm working on MacOSX 10.7.2 and Xcode 4.2.1. I installed libpng using port and I was trying to load a PNG image in my application, but I get linker errors:
Undefined symbols for architecture x86_64:
"_png_create_read_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_create_info_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_destroy_read_struct", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_set_longjmp_fn", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_init_io", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_set_sig_bytes", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_read_png", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_IHDR", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_rowbytes", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
"_png_get_rows", referenced from:
loadPngImage(char*, int&, int&, bool&, unsigned char**) in test.o
ld: symbol(s) not found for architecture x86_64
I included png.h in my project using
#include "/usr/X11/include/png.h"
I know libpng is based on zlib, thus I have included -lz in "Other linker flags" but nothing changed.
Any suggestions on how to make it work?
I solved with a manual installation of libpng:
download the source from official web site
in Terminal, go in the downloaded folder and launch
cp ./scripts/makefile.darwin makefile
make
sudo make install
make clean
if it doesn't work (as in my case) open makefile with TextEdit (or equivalent) and change line
ARCH="-arch i386 -arch x86_64"
in
ARCH=-arch x86_64
(assuming, of course, your system is 64 bit).
It may not be enough. Xcode was still unable to find the library. I solved using
cd /usr/local/lib
sudo ln -s libpng15.dylib ./libpng15.15.dylib
That did the trick. Now it works fine.

Resources