my program was OK to build a few days back. But after I update my gcc/g++ I got compiling errors:
CMakeFiles/tripleClassification.dir/src/tripleClassification.cpp.o: In function `boost::program_options::typed_value<std::string, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const':
tripleClassification.cpp:(.text._ZNK5boost15program_options11typed_valueISscE6xparseERNS_3anyERKSt6vectorISsSaISsEE[_ZNK5boost15program_options11typed_valueISscE6xparseERNS_3anyERKSt6vectorISsSaISsEE]+0x19): undefined reference to `boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, std::string*, int)'
I googled it, it seems to have something to do with gcc version. Can anyone tell me how to change my cmake file to make it work?
Related
When I compile a source file using option:
-lbotan-2
which means using the shared library, nothing goes wrong.
But after I switch to option:
-l:libbotan-2.a
which means using the static library, an error occurs:
//usr/local/lib/libbotan-2.a(pubkey_rsa.o): In function std::future<std::result_of<Botan::Fixed_Exponent_Power_Mod const& (Botan::BigInt const&)>::type> std::async<Botan::Fixed_Exponent_Power_Mod const&, Botan::BigInt const&>(std::launch, Botan::Fixed_Exponent_Power_Mod const&, Botan::BigInt const&)':
rsa.cpp:(.text._ZSt5asyncIRKN5Botan24Fixed_Exponent_Power_ModEJRKNS0_6BigIntEEESt6futureINSt9result_ofIFT_DpT0_EE4typeEESt6launchOS9_DpOSA_[_ZSt5asyncIRKN5Botan24Fixed_Exponent_Power_ModEJRKNS0_6BigIntEEESt6futureINSt9result_ofIFT_DpT0_EE4typeEESt6launchOS9_DpOSA_]+0x379): undefined reference topthread_create'
collect2: error: ld returned 1 exit status
I'm using Botan 2.1.0 and c++11 under Ubuntu 16.04.
Any ideas what goes wrong?
Thanks in advance.
Problem with google test in XCode 4.6.3
Hello all,
I have integrated google tests into my XCode project, and basic command line tool for
unit testing seems to work fine (guest.framework added, DYLD_LIBRRY_PATH set correctly).
However, as soon as I add to object fixture EXPECT_EQ(0, Object.PublicMember) type
test, I get following linker error.
Ld /Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug/UnitTest normal x86_64
cd /Users/rinkevic/Development/VeloxChemX
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug -F/Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug -F/Users/rinkevic/Development/Frameworks -F/Users/rinkevic/Development/VeloxChemX/../../Library/Frameworks -F/Users/rinkevic/Development/VeloxChemX/../Frameworks -filelist /Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Intermediates/VeloxChemX.build/Debug/UnitTest.build/Objects-normal/x86_64/UnitTest.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -framework gtest -framework OpenCL -o /Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug/UnitTest
Undefined symbols for architecture x86_64:
"testing::internal::EqFailure(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&) in TestCartMom.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestion what I am doing wrong?
I had the same problem.
Choose libstdc++ in both projects.
It's because the build options of your unit test project is different with the gtest project.
Make sure the build options such as "Apple LLVM - Language" & "Apple LLVM - Language - C++" are all the same.
Another solution is outlined here: http://dennycd.me/google-test-xcode-mac-osx/ which brings some sanity to the situation by not using a framework but instead installing into /usr/local.
Remember that the libs must be renamed to start with 'lib', for example libgtest.a.
Also remember that you must link to both libgtest.a and libgtest_main.a. Without the latter, you will get a complaint about missing the main method.
The same comments regarding the c++ dialect and the library are applicable, but I found it very hard to control these while producing the framework and trying to link to that.
By default General.xcconfig points to 10.4 SDK, changing it to 10.10 fixed issue for me
I have a program that runs correctly when using .png files.
I'm trying to convert it to support OpenEXR.
The program is compiled with macports g++-mp-4.5, and links against macports's openexr1.7.
Relevant parts of the compile line:
/opt/local/bin/g++-mp-4.5 ... -I/opt/local/include/OpenEXR -I/opt/local/include/OpenEXR file.cc ...
-L/opt/local/lib -lIlmImf -lHalf ...
When run, it does this when it tries to call the exr library:
libc++abi.dylib: terminate called throwing an exception
When it is changed to link with the .a files
/opt/local/lib/libIlmImf.a /opt/local/lib/libHalf.a
it gives a link error
Undefined symbols for architecture x86_64:
"Iex::throwErrnoExc(std::basic_string, std::allocator > const&)", referenced from:
Imf::(anonymous namespace)::writeLineOffsets(Imf::OStream&, std::vector > const&) in libIlmImf.a(ImfOutputFile.o)
Imf::StdIFStream::StdIFStream(char const*) in libIlmImf.a(ImfStdIO.o)
Imf::(anonymous namespace)::checkError(std::basic_istream >&, long) in libIlmImf.a(ImfStdIO.o)
After searching, it seems that this (*undefined symbols for x86_64*) is a common problem for linux-style mac development, and does not appear to be specific
to openexr. However after reading various posts, I still do not understand what the solution is!
Here is a post on the exact problem, however the solution is not explained in enough detail for me to understand:
http://lists.nongnu.org/archive/html/openexr-devel/2011-08/msg00007.html
I am trying to build LLVM and link it against libc++, but I can't get it to work. I downloaded the latest version (LLVM 3.2).
$ CXXFLAGS=-stdlib=libc++ LDFLAGS=-stdlib=libc++ ../llvm-3.2.src/configure
$ make
llvm[0]: Constructing LLVMBuild project information.
llvm[1]: Compiling APFloat.cpp for Release+Asserts build
llvm[1]: Compiling APInt.cpp for Release+Asserts build
(etcetera)
llvm[1]: Building Release+Asserts Archive Library libLLVMTableGen.a
llvm[2]: Compiling FileCheck.cpp for Release+Asserts build
llvm[2]: Linking Release+Asserts executable FileCheck (without symbols)
Undefined symbols for architecture x86_64:
"std::string::find_last_not_of(char, unsigned long) const", referenced from:
llvm::SMDiagnostic::print(char const*, llvm::raw_ostream&, bool) const in libLLVMSupport.a(SourceMgr.o)
"std::string::copy(char*, unsigned long, unsigned long) const", referenced from:
llvm::sys::Path::makeUnique(bool, std::string*) in libLLVMSupport.a(Path.o)
"std::string::find(char const*, unsigned long, unsigned long) const", referenced from:
llvm::sys::getDefaultTargetTriple() in libLLVMSupport.a(Host.o)
"std::string::find(char, unsigned long) const", referenced from:
llvm::sys::Program::FindProgramByName(std::string const&) in libLLVMSupport.a(Program.o)
(followed by a bunch of other related linker errors)
Complete output on Gist.
LLVM compiles and links fine with libstdc++, but not with libc++. I have no idea why it won't link with libc++; other programs just link fine. I am running OS X Mountain Lion and libc++ is in /usr/lib/libc++.1.dylib. The compiler used is Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn).
Trust me, I'm not expert in this area. But try this:
../llvm/configure --enable-libcpp
And in general I've found:
../llvm/configure --help
quite helpful.
I'm using Qt4.8 on OSX Leopard and instead of qmake+QtCreator I want to compile a very simple project using CMake on OSX to understand how to do a package.
While the very same project compiles and links smoothly under Linux, under my OSX box, this is the error message I always get in the linking phase:
ld warning: in /Library/Frameworks//QtGui.framework/QtGui, file is not of required architecture
ld warning: in /Library/Frameworks//QtCore.framework/QtCore, file is not of required architecture
Undefined symbols:
"QWidget::mousePressEvent(QMouseEvent*)", referenced from:
vtable for TestFormin moc_TestForm.cxx.o
"QObject::childEvent(QChildEvent*)", referenced from:
vtable for TestFormin moc_TestForm.cxx.o
"QWidget::actionEvent(QActionEvent*)", referenced from:
vtable for TestFormin moc_TestForm.cxx.o
"QCoreApplication::translate(char const*, char const*, char const*, QCoreApplication::Encoding)", referenced from:
etcetera etcetera.
This happens for every project I want to compile with cmake.
Any idea of what's going on?
Check what architecture (i386,x86_64) is being used by cmake (CMAKE_OSX_ARCHITECTURES). Try suggesting the architecture to cmake:
cmake -DCMAKE_OSX_ARCHITECTURES=x86_64