Linking against gtest: conan builds vs regular cmake builds
A-Alaa opened this issue · 3 comments
Describe the bug
Linking errors raise when building the project and linking against the libraries installed by conan.
Errors sample:
CMakeFiles/features.dir/featuresTest.cpp.o: In function `testing::AssertionResult testing::internal::CmpHelperEQFailure<long long, int>(char const*, char const*, long long const&, int const&)':
/home/asem/.conan/data/gtest/1.8.1/bincrafters/stable/package/4a8c5b4cd3b4d45b83fff85d53160ea02ae5fa2d/include/gtest/gtest.h:1435: undefined reference to `testing::internal::EqFailure(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
The linking issue is fixed when linking the khiva tests against the same gtest version 1.8.0 that is built from its main repository.
Sample from CMakeCache.txt before fixing
//Path to a file.
GTEST_INCLUDE_DIRS:PATH=/home/asem/.conan/data/gtest/1.8.1/bincrafters/stable/package/4a8c5b4cd3b4d45b83fff85d53160ea02ae5fa2d/include
//Path to a library.
GTEST_LIBRARIES:FILEPATH=/home/asem/.conan/data/gtest/1.8.1/bincrafters/stable/package/4a8c5b4cd3b4d45b83fff85d53160ea02ae5fa2d/lib/libgtest.a
//Path to a library.
GTEST_MAIN_LIBRARIES:FILEPATH=/home/asem/.conan/data/gtest/1.8.1/bincrafters/stable/package/4a8c5b4cd3b4d45b83fff85d53160ea02ae5fa2d/lib/libgtest_main.a
After fixing
//Path to a file.
GTEST_INCLUDE_DIRS:PATH=/opt/gtest/include
//Path to a library.
GTEST_LIBRARIES:FILEPATH=/opt/gtest/lib/libgtest.a
//Path to a library.
GTEST_MAIN_LIBRARIES:FILEPATH=/opt/gtest/lib/libgtest_main.a
I am just reporting this case since it costed me a lot of time! Couldn't expect that conan might be the reason.
Hi Asem,
I tried to reproduce this issue, but everything worked smoothly for me. Moreover, I realised all nightly builds (Windows, Linux and MacOs) are fine, could you give us some more information about your running environment? (Like S.O., compiler versions and so on ...), so we can assist you.
Thanks a lot, for reporting these issues and contributing.
Antonio Vilches.
Hi again Asem,
Please check your default conan profile file, in this path: ~/.conan/profiles/default.
You must have the following setting enabled for c++11.
compiler.libcxx=libc++11
I hope it solves your problems, if not, let us know your running environment, so we can do further analysis.
Hi again Asem,
Please check your default conan profile file, in this path: ~/.conan/profiles/default.
You must have the following setting enabled for c++11.
compiler.libcxx=libc++11
I hope it solves your problems, if not, let us know your running environment, so we can do further analysis.
This has solved it very smoothly! Thank you!