Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on ubuntu 16.04 with gcc 5.4 #7

Open
Phibedy opened this issue Oct 31, 2016 · 3 comments
Open

Build fails on ubuntu 16.04 with gcc 5.4 #7

Phibedy opened this issue Oct 31, 2016 · 3 comments

Comments

@Phibedy
Copy link
Contributor

Phibedy commented Oct 31, 2016

New ubuntu 16.04

//install basics
//automake/libtool is needed for protobuffers
sudo apt-get update
sudo apt-get install python python-pip build-essential make git cmake automake libtool
//install conan
sudo pip install conan
//add remote to conan
conan remote add lms http://mineforce.de:9300
conan install lms/2.0@lms/stable --build=missing

Error

[100%] Linking CXX executable bin/lms
liblmscore.so: undefined reference to `google::protobuf::internal::empty_string_'
liblmscore.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)'
liblmscore.so: undefined reference to `pugi::xml_node::path(char) const' #Some other lib we have to fix
liblmscore.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
liblmscore.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
liblmscore.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const'
liblmscore.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::Delete(std::string*)'
liblmscore.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))'
liblmscore.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
liblmscore.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::New()'
liblmscore.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
liblmscore.so: undefined reference to `google::protobuf::Message::GetTypeName() const'
collect2: error: ld returned 1 exit status
CMakeFiles/lms.dir/build.make:95: recipe for target 'bin/lms' failed
make[2]: *** [bin/lms] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/lms.dir/all' failed
make[1]: *** [CMakeFiles/lms.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

lms/2.0@lms/stable: ERROR: Package '13a8d081f533db91339ab619a0f71485c8820c78' build failed
lms/2.0@lms/stable: WARN: Build folder /home/phoenix/.conan/data/lms/2.0/lms/stable/build/13a8d081f533db91339ab619a0f71485c8820c78
ERROR: lms: Error 512 while executing cmake --build . 

It works on ubuntu 14.04 with gcc 4.8 and 6.2.

@owend
Copy link

owend commented Apr 12, 2017

A quick fix is to add this to the CMakeLists.txt for your project

add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

Although the conan docs suggest that it should also work, for some reason specifying libstdc++ (vs libstdc++11) doesn't trigger this flag for me, which caused the build to fail with the same error you're seeing. If I have time I'll track down the root cause.

@memsharded
Copy link
Owner

That is true, the add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) is automatically defined only when used from a conanfile.py recipe with the CMake helper.

Check: https://github.com/conan-io/conan/blob/develop/conans/client/generators/cmake_common.py#L171

This only works when the CONAN_LIBCXX is defined, which is done by the CMake helper, typically used in the build() method of the recipe.

The root cause is the high decoupling between conan and the build system. When you install conan dependencies you specify some settings, and a conanbuildinfo.cmake is generated for those settings. But when you are building your project, your project settings must match the installed dependencies. For some of them, like the compiler and compiler version, the conanbuildinfo.cmake already implements some checks, but not for the libcxx.

I have added an issue (conan-io/conan#1202) to the main conan repo, to try to improve this (even if it doesn't look easy without breaking the low coupling). Thanks for the feedback!

@owend
Copy link

owend commented Apr 12, 2017

Thanks for noticing! :) What's strange about this is that I built all dependencies from source with the same compiler and no specific settings or overrides, but still ended up with two different CXX11 versions somehow. I checked the conaninfo.txt file in the build dir of the Protobuf dependency and everything matched. Happy to provide any further details if you need them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants