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.
Related
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
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)
I am currently trying to compile a Contraction Hierachies implementation by KIT which requires Boost::Regex. The supplied Makefile already makes sure (and I have also double-checked this manually) that g++ is supplied with the -lboost_regex switch. If the library is not installed, g++ will complain.
So I installed the library from my package sources and tried compiling again. This time I am getting a huge load of linker errors regarding Boost::Regex. Here is a short excerpt:
main.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::unwind_extra_block(bool)':
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb]+0x2c): undefined reference to `boost::re_detail::put_mem_block(void*)'
main.o: In function `void boost::re_detail::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type)':
main.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0x7d): undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
main.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0xb1): undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
main.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0xcb): undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
main.o: In function `__gnu_cxx::__normal_iterator<char const*, std::string> boost::re_detail::re_is_set_member<__gnu_cxx::__normal_iterator<char const*, std::string>, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::re_detail::re_set_long<unsigned int> const*, boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool)':
main.cpp:(.text._ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb[_ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb]+0x17b): undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const'
main.cpp:(.text._ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb[_ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb]+0x4c0): undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const'
main.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::extend_stack()':
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12extend_stackEv[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12extend_stackEv]+0x18): undefined reference to `boost::re_detail::get_mem_block()'
main.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_imp()':
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv]+0xc): undefined reference to `boost::re_detail::get_mem_block()'
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv]+0x19e): undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv]+0x254): undefined reference to `boost::re_detail::put_mem_block(void*)'
main.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv]+0x3c6): undefined reference to `boost::re_detail::put_mem_block(void*)'
This looks very much like the compiler did not find the library at all. In fact, when I don't supply the -lboost_regex switch the output remains the same (I ran a hash on it).
However, running the linker with the -Wl,--verbose switch as suggested in nuwen MinGW + Boost- error linking boost_regex shows that the library is found:
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_regex.so succeeded
-lboost_regex (/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libboost_regex.so)
All I know is that this is likely a different boost version than what was around when the software was written (I don't know which. I am using 1.53 now.) but from looking at the code it seems it should still work. Also I am using the headers from this boost version so the compiler should already complain if function signatures have changed.
How can I get this to link? Am I missing something?
Linker switches are in the wrong order. make tries to do this:
g++ -lboost_regex -lboost_iostreams -o main main.o
This is what actually works (at least with gcc 4.8.1):
g++ -o main main.o -lboost_regex -lboost_iostreams
So to fix the compilation error you should substitue line 6 in the Makefile with the following:
$(CXX) -o $# $^ $(LIBS) $(LINK)
Boost regex (and other boost libs, probably) may also fail to link if you have multiple versions of boost available, and the linker path and include paths point to different versions (this happened to me with cmake when using find_package(Boost ...) where a path was specified while also having a different version installed in the system root.
The solution in the case of cmake was to add include_directories(${Boost_INCLUDE_DIRS}) to CMakeLists.txt as well as ensuring the correct link ordering in the target_link_libraries.
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.
I'm trying to compile basic plugin for firefox and linker reports following problem:
Undefined symbols for architecture i386:
"_NPN_GetValue", referenced from:
_PluginLog in main.o
"_NPN_GetStringIdentifier", referenced from:
_PluginLog in main.o
"_NPN_GetProperty", referenced from:
_PluginLog in main.o
"_NPN_Invoke", referenced from:
_PluginLog in main.o
"_NPN_ReleaseObject", referenced from:
_PluginLog in main.o
"_NPN_ReleaseVariantValue", referenced from:
_PluginLog in main.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
have I missed to add some linked libraries?
You can't just call those functions like you would a normal function (they aren't exported by a browser, nor are you linking against a browser); you need to use the function pointers from the NPNetscapeFuncs struct passed to you by the browser.