-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
gtest/[0.13.0, 0.14.0]: Undefined references to "basic_string" on clang-17 with "compiler.libcxx=libstdc++11" #22547
Comments
Hello @matheusgomes28 ! It's not totally clear how you are consuming the Conan package. Your profile looks okay, but how do you consume that library? Please, make sure you are using |
@uilianries sorry if it wasn't clear. I am using I've used Conan before and am familiar with the ABI issue, but can't seem to fix here 😕 For context, I am building this on a CI in this branch of my project |
@matheusgomes28 Could you please point the exact link to the build that's failing? So I can have a better view. Plus, you should prefer https://docs.conan.io/2/reference/conanfile_txt.html#test-requires |
@uilianries I can, its the "Ubuntu Debug" build that builds unit tests. However, don't worry about that, I think it's counter productive trying to understand my CI pipeline. I've made a minimal reproducible project that also fails. Firstly, install the Project File Setup (all same dir)CMakeLists.txt: cmake_minimum_required(VERSION 3.25)
project(ConanGtest LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(GTest REQUIRED)
add_executable(tests main.cpp)
target_link_libraries(tests PRIVATE GTest::gtest) main.cpp: #include <gtest/gtest.h>
#include <string>
// NOLINTNEXTLINE
TEST(MyTestCase, MyTestName)
{
std::string const expected{"Hello World!"};
ASSERT_EQ(expected, "Hello World!");
}
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} conanfile.txt [requires]
gtest/1.13.0
[generators]
CMakeDeps
CMakeToolchain Commands Used to BuildConan dependency install CC="clang-17" CXX="clang-17" conan install . -of "conan/deb" -sbuild_type=Debug --build=missing CMake configure cmake -DCMAKE_TOOLCHAIN_FILE="conan/deb/conan_toolchain.cmake" -DCMAKE_CXX_COMPILER="clang-17" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_CXX_COMPILER="clang-17" . -Bbuild CMake build cmake --build ./build And you should get the linking errors on the build stage. Note that I have used the same profile as mentioned before. |
@matheusgomes28 It's working fine for me:
Some important considerations:
|
@uilianries Thank you very much for trying it out and providing your workflow. I figured the issue is the Is there a reason why Conan supports
|
@matheusgomes28 Now I see your error, is about C++20, not C++17 like you described in your Conan profile in this issue description!!!
Not true!! I'll explain: There is another related issue (spdlog) with same error somewhere (I couldn't find). The thing is: You are consuming the pre-built binary of GTest from Conan Center. It was built using C++14, which Conan takes as ABI compatible. However, there is a breaking in C++20 that does not make it compatible (it works for C++17). Right now, we have a new feature to Conan (conan-io/conan#15348) to make it incompatible between C++14 and C++20. You have to do: Build GTest from sources
It will cache a new package of Gtest, using your defined compiler.cppstd. |
@uilianries I had built from source as well with the std set to 20 in the profile before btw, but no luck. I'll run a few more tests after work and I'll port the findings here! I.e. I was not consuming a pre built package, I also tried |
@matheusgomes28 It should work, if you are doing it locally, please remove all your cache related to gtest: |
@uilianries Confirmed locally, works on |
@matheusgomes28 Thank you for your feedback 😸 |
Description
Linking Google Test with Clang 17 does not seem to be working, we get the errors shown in the logs.
Obviously, I am well aware of the many issues reported regarding the
std::basic_string
ABI differences between building withlibstd++
andlibstdc++11
. But even after setting compiler.libcxx=libstdc++11 it does NOT work when linking the lib to a binary.I've also tried to manually tweek the
_GLIBCXX_USE_CXX11_ABI
, but no fixes so far.Is this a bug, or am I missing something?
Package and Environment Details
General Info
Environment Variables Defined
Conan profile
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=17
os=Linux
Profile build:
[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=17
os=Linux
Steps to reproduce
helper script used (called
conan-install.sh
):So I'm calling the script above with
COMPILER="clang" COMPILER_VERSION="17" COMPILER_CPPSTD="20" COMPILER_LIBCXX="libstdc++11" ./scripts/helpers/conan-install.sh
Logs
The text was updated successfully, but these errors were encountered: