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

Does not build with googletest 1.13 #29

Closed
mkoeppe opened this issue Jun 21, 2023 · 10 comments · Fixed by #30
Closed

Does not build with googletest 1.13 #29

mkoeppe opened this issue Jun 21, 2023 · 10 comments · Fixed by #30
Assignees

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 21, 2023

Both on macOS with latest Xcode

[cmr-5887831f71679dcf4801a0079733d666ac06404f] [100%] Linking CXX executable cmr_gtest
[cmr-5887831f71679dcf4801a0079733d666ac06404f] Undefined symbols for architecture x86_64:
[cmr-5887831f71679dcf4801a0079733d666ac06404f]   "testing::InitGoogleTest(int*, char**)", referenced from:
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       _main in test_main.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]   "testing::AssertionResult::AssertionResult(testing::AssertionResult const&)", referenced from:
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       testing::AssertionResult testing::internal::CmpHelperOpFailure<int, unsigned long>(char const*, char const*, int const&, unsigned long const&, char const*) in test_graph.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]   "testing::AssertionFailure()", referenced from:
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       testing::AssertionResult testing::internal::CmpHelperOpFailure<int, unsigned long>(char const*, char const*, int const&, unsigned long const&, char const*) in test_graph.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]   "testing::AssertionSuccess()", referenced from:
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       ComplementTotalUnimodularity_Examples_Test::TestBody() in test_ctu.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       Graph_Modifications_Test::TestBody() in test_graph.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       Regular_OneSum_Test::TestBody() in test_regular.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       Regular_SeriesParallelTwoSeparation_Test::TestBody() in test_regular.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       Regular_NestedMinorSearchTwoSeparation_Test::TestBody() in test_regular.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       Regular_R10_Test::TestBody() in test_regular.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       Regular_R12_Test::TestBody() in test_regular.cpp.o
[cmr-5887831f71679dcf4801a0079733d666ac06404f]       ...

and also on ubuntu-focal with default GCC

Any hints?

(I'm trying to add it to Sage - sagemath/sage#35801)

@discopt
Copy link
Owner

discopt commented Jun 21, 2023

Adding CMR to Sage would be great! If any API changes are needed, just let me know!

Regarding the compilation/linking bug: I tried with googletest 1.13 under KUbuntu 22.04 with default gcc 11.3 and did not see any problems. Can you maybe try to build with make VERBOSE=1?

[ 83%] Linking CXX executable cmr_gtest
cd <DIR>/build-debug/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/cmr_gtest.dir/link.txt --verbose=1
/usr/bin/c++ -g
 CMakeFiles/cmr_gtest.dir/common.c.o CMakeFiles/cmr_gtest.dir/test_camion.cpp.o CMakeFiles/cmr_gtest.dir/test_ctu.cpp.o CMakeFiles/cmr_gtest.dir/test_graph.cpp.o CMakeFiles/cmr_gtest.dir/test_graphic.cpp.o CMakeFiles/cmr_gtest.dir/test_hashtable.cpp.o CMakeFiles/cmr_gtest.dir/test_matrix.cpp.o CMakeFiles/cmr_gtest.dir/test_main.cpp.o CMakeFiles/cmr_gtest.dir/test_network.cpp.o CMakeFiles/cmr_gtest.dir/test_regular.cpp.o CMakeFiles/cmr_gtest.dir/test_separation.cpp.o CMakeFiles/cmr_gtest.dir/test_series_parallel.cpp.o CMakeFiles/cmr_gtest.dir/test_tu.cpp.o
 -o cmr_gtest  -Wl,-rpath,<DIR>/build-debug/lib:<DIR>build-debug ../lib/libgtest_main.so.1.13.0 ../libcmr.so ../lib/libgtest.so.1.13.0 

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2023

Log with VERBOSE=1
cmr-5887831f71679dcf4801a0079733d666ac06404f.log

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2023

Same on ubuntu-jammy.
Are you using googletest built from source or an ubuntu package?

@discopt
Copy link
Owner

discopt commented Jun 21, 2023

The relevant call is

/Library/Developer/CommandLineTools/usr/bin/g++   -std=gnu++14 -g -O2 -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/Users/mkoeppe/s/sage/sage-rebasing/local/lib -Wl,-rpath,/Users/mkoeppe/s/sage/sage-rebasing/local/lib -L/Users/mkoeppe/s/sage/sage-rebasing/local/lib -Wl,-rpath,/Users/mkoeppe/s/sage/sage-rebasing/local/lib
 CMakeFiles/cmr_gtest.dir/common.c.o CMakeFiles/cmr_gtest.dir/test_camion.cpp.o CMakeFiles/cmr_gtest.dir/test_ctu.cpp.o CMakeFiles/cmr_gtest.dir/test_graph.cpp.o CMakeFiles/cmr_gtest.dir/test_graphic.cpp.o CMakeFiles/cmr_gtest.dir/test_hashtable.cpp.o CMakeFiles/cmr_gtest.dir/test_matrix.cpp.o CMakeFiles/cmr_gtest.dir/test_main.cpp.o CMakeFiles/cmr_gtest.dir/test_network.cpp.o CMakeFiles/cmr_gtest.dir/test_regular.cpp.o CMakeFiles/cmr_gtest.dir/test_separation.cpp.o CMakeFiles/cmr_gtest.dir/test_series_parallel.cpp.o CMakeFiles/cmr_gtest.dir/test_tu.cpp.o
 -o cmr_gtest  -Wl,-rpath,/Users/mkoeppe/s/sage/sage-rebasing/local/var/tmp/sage/build/cmr-5887831f71679dcf4801a0079733d666ac06404f/src/build -lgtest_main ../libcmr.dylib 

which links the compiled unit tests to libgtest_main (see end of command). So the linker calls seems to be appropriate.

@discopt
Copy link
Owner

discopt commented Jun 21, 2023

Same on ubuntu-jammy. Are you using googletest built from source or an ubuntu package?

I tried both. By default, I use the Ubuntu googletest sources, but commenting out lines 1 and 3 cmr/test/CMakeLists.txt forces it to clone and build the googletest git version, which also worked for me.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2023

OK, thanks. I must be doing something wrong in my install script for googletest then.

I have now allowed cmr to clone the googletest sources, and it built successfully. Sorry for the noise!

@mkoeppe mkoeppe closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
@discopt
Copy link
Owner

discopt commented Jun 21, 2023

I looked at the symbol tables of my googletest: For me, the final linker call links to libgtest_main.so.1.13.0 and to libgtest.so.1.13.0, and the latter contains the relevant symbols. Your call from the log file only links to the former.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2023

Thanks! I'll investigate.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2023

OK. It turns out that my installation of gtest has built static libraries only.
Also the homebrew package is configured in this way.

@mkoeppe mkoeppe reopened this Jun 21, 2023
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2023

Even after switching to shared libraries in my build (and getting rid of the homebrew package), I'm getting the same error; but I've found a simple solution

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

Successfully merging a pull request may close this issue.

2 participants