Skip to content

Commit 9285806

Browse files
committed
Set gtest to static to fix:
[ 95%] Linking CXX executable ../../bin/ImageTests /usr/bin/ld: ../../lib/libgtest_main.so.1.11.0: undefined reference to `std::ios_base_library_init()@GLIBCXX_3.4.32' collect2: error: ld returned 1 exit status make[2]: [Testing/ImageTests/CMakeFiles/ImageTests.dir/build.make:500: bin/ImageTests] Error 1 make[1]: [CMakeFiles/Makefile2:1273: Testing/ImageTests/CMakeFiles/ImageTests.dir/all] Error 2 The problem is that there is libstdc++ from conda and from the system and they don't have the same versioned symbols.
1 parent 63e67eb commit 9285806

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Testing/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# GTest setup
22
#find_package(GTest REQUIRED)
33

4+
set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS})
5+
set(BUILD_SHARED_LIBS OFF)
6+
47
# fetch googletest
58
include(FetchContent)
69
FetchContent_Declare(
@@ -14,6 +17,10 @@ if(NOT googletest_POPULATED)
1417
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
1518
endif()
1619

20+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
21+
22+
# Restore BUILD_SHARED_LIBS
23+
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED})
1724

1825
# NOTE: must call enable_testing() before this in the top-level CMakeLists.txt
1926

0 commit comments

Comments
 (0)