I'm building a project that requires boost's text_oarchive function, and am getting a linker error when trying to build it.
I've installed Boost 1.55.0 on OS X 10.9
My compiler information is reported as:
$g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
The bootstrap.log file in the boost directory reports the "'darwin' toolset" was used.
however, when building from Eclipse, the following error is reported at the end of the build output:
"boost::archive::detail::basic_oarchive::~basic_oarchive()", referenced from:
::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive() in msgQueProducer.o
"typeinfo for boost::archive::archive_exception", referenced from:
void boost::serialization::throw_exception<boost::archive::archive_exception> (boost::archive::archive_exception const&) in msgQueProducer.o
"typeinfo for boost::archive::detail::basic_oarchive", referenced from:
typeinfo for boost::archive::detail::common_oarchive<boost::archive::text_oarchive> in msgQueProducer.o
"vtable for boost::archive::archive_exception", referenced from:
boost::archive::archive_exception::archive_exception(boost::archive::archive_exception const&) in msgQueProducer.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [msgQueProducer] Error 1
The project builds fine when the following single line of code removed from the project:
boost::archive::text_oarchive oa(oss);
I'm wondering if when I built the boost libraries I should have specified some architecture parameters (passing to the ./b2 tool something like "./b2 toolset=darwin cxxflags="-arch i386" address-model=64 architecture=x86 stage"). However, I'm building with another boost function used for interprocess messaging, and the project builds fine with it included.
The boost project includes I'm using are:
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/archive/text_oarchive.hpp>
What do I need to do to use boost::text_oarchive on my OS X system?
Thanks in advance,
Walt
You need to link the boost-serialization library. Add -lboost_serialization to your LDFLAGS.
Related
I am trying to run a C++ project which has also dependence to PBC (https://crypto.stanford.edu/pbc/) and GMP (https://gmplib.org). I have installed PBC and GMP in the /usr/local/ directory. For this project I added the PBC (pbc-0.5.14) and GMP (gmp-6.1.0) libraries manually (I dragged those libraries into my project).
When I add the -lgmp -lgmpxx flags into Other linker flags in Xcode (Version 7.2) I got this:
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I build (and clean) without Other linker flags I got:
Undefined symbols for architecture x86_64:
"_pairing_clear", referenced from:
Member::~Member() in member.o
Manager::~Manager() in manager.o
Verifier::~Verifier() in verifier.o
"_pairing_init_set_str", referenced from:
Member::Member() in member.o
Manager::Manager() in manager.o
Verifier::Verifier() in verifier.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Did anyone know how to fix this issue or any suggestions?
Thanks.
On my Ubuntu 15.10(64), libgmp installed into
> /usr/lib/i386-linux-gnu/libgmp.so.10
> /usr/lib/i386-linux-gnu/libgmp.so.10.2.0
> /usr/lib/i386-linux-gnu/openssl-1.0.0/engines/libgmp.so
> /usr/lib/x86_64-linux-gnu/libgmp.a /usr/lib/x86_64-linux-gnu/libgmp.so
> /usr/lib/x86_64-linux-gnu/libgmp.so.10
> /usr/lib/x86_64-linux-gnu/libgmp.so.10.2.0
> /usr/lib/x86_64-linux-gnu/libgmpxx.a
> /usr/lib/x86_64-linux-gnu/libgmpxx.so
> /usr/lib/x86_64-linux-gnu/libgmpxx.so.4
> /usr/lib/x86_64-linux-gnu/libgmpxx.so.4.4.0
I found this using command "locate libgmp". (locate searches what updatedb updates.)
You say you 'installed' it locally? I ran install without any options. Maybe your linker is not informed about where to look for the libs? Perhaps add a "-L 'local location'"?
Hope this helps ...
I'm trying to play around with the new shared_timed_mutex structures from C++ 14 on OS X 10.11.2 using Eclipse CDT 4.5.0. Xcode is 7.2. I'm using GCC C++ with the following options:
-O0 -g3 -Wall -c -fmessage-length=0 -std=c++14
Her's what I get:
Invoking: MacOS X C++ Linker
g++ -o "MyProject" ./src/main.o
Undefined symbols for architecture x86_64:
"std::__1::shared_timed_mutex::shared_timed_mutex()", referenced from:
HashMap<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<int> >::HashMap() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here's my clang version info:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix
I've searched my way through the web and found a couple of recommendations, for example this one on Reddit:
https://www.reddit.com/r/cpp_questions/comments/3ejfkr/is_c14s_stdshared_timed_mutex_available_on_os_x/?
This is very close to my problem, I've tried the suggestions, but I´m hoping, that I won´t have to do the manual libc++ download, but could stick with the standard libs shipped with my system.
Thank you!
For the past two years (as I write this) Apple has updated the libc++ headers for their tools releases, but not the libc++ sources. And libc++ implements std::shared_time_mutex both in <shared_mutex> and in shared_mutex.cpp.
According to Apple dev presentation the shared_timed_mutex will be available starting with macOS 10.12. See page 52
there are quite a no. of question on this point. But none of them can guide a solution to my issue. I am trying to create a plugin for Adobe Illustrator CC in XCode Version 6.3.2 (6D2105). Following their official guidelines to create a basic "HelloWorld" plugin giving this linker error.
Error:
Ld /Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug/HelloWorld.bundle/Contents/MacOS/HelloWorld normal x86_64
cd "/Users/Barun/Adobe Illustrator CC 2015 SDK/samplecode/HelloWorld"
export MACOSX_DEPLOYMENT_TARGET=10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug -F/Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug -filelist /Users/Barun/Library/Developer/Xcode/DerivedData/HelloWorld-fzhjlvdzxxobzagznysauclanlgg/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/HelloWorld.LinkFileList -mmacosx-version-min=10.9 -dead_strip -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/Barun/Library/Developer/Xcode/DerivedData/HelloWorld-fzhjlvdzxxobzagznysauclanlgg/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/HelloWorld_dependency_info.dat -o /Users/Barun/Adobe\ Illustrator\ CC\ 2015\ SDK/samplecode/output/mac/debug/HelloWorld.bundle/Contents/MacOS/HelloWorld
Undefined symbols for architecture x86_64:
"_CFStringCreateWithCharacters", referenced from:
ai::UnicodeString::as_CFString(__CFAllocator const*) const in IAIUnicodeString.o
"_CFStringGetCharactersPtr", referenced from:
ai::UnicodeString::UnicodeString(__CFString const* const&) in IAIUnicodeString.o
"_CFStringGetLength", referenced from:
ai::UnicodeString::UnicodeString(__CFString const* const&) in IAIUnicodeString.o
"_CFStringGetCharacters", referenced from:
ai::UnicodeString::UnicodeString(__CFString const* const&) in IAIUnicodeString.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Looks like the linking error coming from IAIUnicodeString.cpp file, which is a support file provided by the sdk. So I am not having idea to what need to be change there.
I was successful to build FreeGrid and DrawArt project provided with the SDK as sample. I have also checked all the build settings with FreeGrid to my HelloWorld project, no mismatch from that side too.
The project set up can be found in Github.
From Adobe Forum https://forums.adobe.com/message/7723859#7723859:
Add to project settings:
BuildPhases>Link Binary With Libraries: CoreFoundation.framework
I have a very simple class, which I will send as Object via TCP using Asio by boost. I found many examples on the Internet, but when I compile my code I get a Link Failure.
#include <boost/archive/text_oarchive.hpp>
void async_write(){
std::ostringstream archive_stream;
boost::archive::text_oarchive archive(archive_stream); // here it fails
//....
}
I downloaded boost via macports.
My Qt project file:
INCLUDEPATH += /opt/local/include
LIBS += -L/opt/local/lib
LIBS += -lboost_system-mt -lboost_filesystem-mt -lboost_serialization-mt
Failure:
Undefined symbols for architecture x86_64:
"boost::archive::text_oarchive_impl::save(std::string const&)", referenced from:
void boost::archive::save_access::save_primitive(boost::archive::text_oarchive&, std::string const&) in tcpsession.o
"boost::archive::text_oarchive_impl::text_oarchive_impl(std::ostream&, unsigned int)", referenced from:
boost::archive::text_oarchive::text_oarchive(std::ostream&, unsigned int) in tcpsession.o
"boost::archive::basic_text_oprimitive::~basic_text_oprimitive()", referenced from:
boost::archive::text_oarchive_impl::~text_oarchive_impl() in tcpsession.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: * [tcpserver] Error 1
Any help is appreciated.
The standard reply would be "re-run qmake". It's even simpler to just delete the entire shadow build directory. One level up from the source of your project, there will be build-... folders. Delete all of them, and build again.
The simplest way to see whether your project file (the file with LIBS += lines) is current, add something to it that's invalid (like a typo in the library name). If it still "builds" without showing the error directly aimed at your typo (a missing library), then you know that your build is not based on the current project file, and you should re-run qmake or delete the shadow build folder so that everything will be recreated there.
I'm having a compilation issue which I'm unable to solve. I'm developing a cross platform C++ project coding on both Mac Os X 10.8 and Windows. The code compiles and run fine on Windows and on Mac Os X Leopard as well.
Since Apple pushes the developers to stick to the latest platform for various reasons I'm forced to develop on Mountain Lion and I'm trying to get the project to work again.
I compiled correctly all the libraries I needed (wxWidgets, etc) and I imported the project in the latest version of Eclipse. When I try to build the project it tries to compile the firts .cpp file and at the end it (why?) tries to invoke the linker resulting on a series of missing symbols for my own defined classes. None of the other .cpp files is being compiled, so it's pretty understendable why the whole process is failing.
I also tried to invoke make from CLI, with the same result. I went into the makefile and everything seems correct. It looks like a very newbie issue, I feel I'm missing something huge here.
I'm pasting below the output of the compiler, just in case some compiling guru step in. Please feel free to ask for more details.
Compiler output
Pastebin Link: Compiler output
I used PB since the output is quite large.
The relevant section are the invocation of as and collect2 soon after the compiling phase of the very first .cpp file. The missing symbols are defined in other .cpp files in the same dir.
/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/br/h6ln_j014ll56zwc8x6xjmk80000gn/T//ccSUmHal.o /var/folders/br/h6ln_j014ll56zwc8x6xjmk80000gn/T//ccn8ex81.s
/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/collect2 -dynamic -arch x86_64 -macosx_version_min 10.8.3 -weak_reference_mismatches non-weak -o Calcoli.o -lcrt1.10.6.o -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64 -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1 -L/usr/llvm-gcc-4.2/bin/../lib/gcc -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1 -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../.. -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../.. /var/folders/br/h6ln_j014ll56zwc8x6xjmk80000gn/T//ccSUmHal.o -lstdc++ -lSystem -lgcc -lSystem
The compiler output ends with the "classic" undefined symbol issue. All emphasized text*emphasized text*emphasized text
Undefined symbols for architecture x86_64:
"typeinfo for TipoPuntoCalc", referenced from:
Calcoli::setPuntoS(GTGraphicObject*) in ccSUmHal.o
"typeinfo for TipoPali", referenced from:
Calcoli::setPaloS(GTGraphicObject*) in ccSUmHal.o
"typeinfo for TipoRett", referenced from:
Calcoli::setFondazioneS(GTGraphicObject*) in ccSUmHal.o
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [Calcoli.o] Error 1
This shouldn't be an architecture related issue, since specifing i386 as target has the same result (symbol(s) not found for architecture i386).
Thank you,
Evelina
Go to your target's "Build Phases" section and verify that all the files you need to compile and link are actually included in the proper sections.
It sounds as if the compiler is not being told to include some things you need.