-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Error linking libgtest.so to cartographer #1611
Comments
(this is a non-Ninja build, since Ninja causes different problems...) It looks like all of
|
The problem is due to incompatibility between Cartographer and the system packages I had to remove these packages, and compile and install all these packages from source to get most of cartographer_ros to build. However, cartographer itself still does not build, even with these freshly-built libraries:
|
I resolved the issue by modifying the diff --git a/cmake/modules/FindGMock.cmake b/cmake/modules/FindGMock.cmake
index c663e98..9afa068 100644
--- a/cmake/modules/FindGMock.cmake
+++ b/cmake/modules/FindGMock.cmake
@@ -30,6 +30,14 @@ if(NOT GMock_FOUND)
PATHS
/usr
)
+ find_library(GTEST_LIBRARIES
+ NAMES gtest
+ PATH_SUFFIXES lib
+ )
+ find_library(GMOCK_A_LIBRARIES
+ NAMES gmock
+ PATH_SUFFIXES lib
+ )
# Find system-wide gtest header.
find_path(GTEST_INCLUDE_DIRS gtest/gtest.h
@@ -65,7 +73,7 @@ if(NOT GMock_FOUND)
# System-wide installed gmock library might require pthreads.
find_package(Threads REQUIRED)
- list(APPEND GMOCK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND GMOCK_LIBRARIES ${GMOCK_A_LIBRARIES} ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
include(FindPackageHandleStandardArgs) |
@kunaltyagi Thanks, it worked for me. |
@kunaltyagi, your patch worked for me on Fedora 32. It would be great to see this merged. |
Did you test with the master? There appears to be a similar code update on 2020 June 10, commit db85e08 |
I'm using the released version of cartographer for Eloquent, not master. That change appears to affect the include directories, but this issue describes a linking problem. I tried applying the commit you referenced, but it does not resolve this issue. |
I just encountered a similar linking issue in a Ubuntu 18.04 environment, with system packages The problem is that FindGMock.cmake sets variable diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe1289d..27e4aac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -301,7 +301,7 @@ target_include_directories(${TEST_LIB} SYSTEM PRIVATE
if (WIN32)
target_compile_definitions(${TEST_LIB} PUBLIC -DGTEST_LINKED_AS_SHARED_LIBRARY)
endif()
-target_link_libraries(${TEST_LIB} PUBLIC ${GMOCK_LIBRARY})
+target_link_libraries(${TEST_LIB} PUBLIC ${GMOCK_LIBRARIES})
target_link_libraries(${TEST_LIB} PUBLIC ${PROJECT_NAME})
set_target_properties(${TEST_LIB} PROPERTIES
COMPILE_FLAGS ${TARGET_COMPILE_FLAGS}) |
I encounter this issue when building cartographer_ros on Fedora 29 (without Ninja):
It looks like
-lgtest
is missing from the commandline, e.g. from another broken linkage:The text was updated successfully, but these errors were encountered: