osrf/osrf_testing_tools_cpp

Add pthread for target_link_libraries.

zhoukejun opened this issue · 5 comments

Add pthread for target_link_libraries.

pthread was used in this software, but the pthread libraries was missing.

Please add the pthread in the file: "test_osrf_testing_tools_cpp/CMakeLists.txt".

@@ -22,10 +22,11 @@ if(BUILD_TESTING)
if(NOT WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
add_executable(test_example_memory_tools_gtest test/test_example_memory_tools.cpp)
target_link_libraries(test_example_memory_tools_gtest
gtest_main
osrf_testing_tools_cpp::memory_tools

  •  pthread
    
    )
    get_target_property(extra_env_vars
    osrf_testing_tools_cpp::memory_tools LIBRARY_PRELOAD_ENVIRONMENT_VARIABLE)
    osrf_testing_tools_cpp_add_test(test_example_memory_tools
    COMMAND "$<TARGET_FILE:test_example_memory_tools_gtest>"

@zhoukejun if you have suggested changes, it's easiest for us to review them if you create a pull request.

Additionally, can you please share more about your build environment which requires this change?

The test_osrf_testing_tools_cpp uses std::thread rather than pthread directly and I don't think that linking against pthread should be required. If there's an issue with the build caused by the CMake configuration not linking pthread due to a false positive heuristic check (as was resolved in #21) that may have a different solution.

@nuclearsandwich Thank you for your information. I found this issue when I building the microROS git project.

Which microROS tutorial or documentation were you following? We need to be able to reproduce the issue to assist. So please be detailed and precise.

Are you using the microROS fork of this repository (https://github.com/microROS/osrf_testing_tools_cpp) which is missing recent changes including #21 which links pthread unconditionally?

@nuclearsandwich Yes, you're right. I was using that microROS fork. So the problem was caused by missing new changes. Thank you.

So the problem was caused by missing new changes.

I don't actually know if that's the case. I would suggest you try to add that patch and see if it resolves your issue. Since this error did not occur with this repository, I am closing the issue for now. Feel free to re-open it if it's reproducible with the current master branch.