atenpas / gpg

Generate grasp pose candidates in point clouds
BSD 2-Clause "Simplified" License
104 stars 60 forks source link

libgrasp_candidates_generator.so:对‘boost::this_thread::hidden::sleep_until(timespec const&)’未定义的引用 #14

Open nuo-code opened 2 years ago

nuo-code commented 2 years ago

Hello, I encountered an error when using your library,libgrasp_candidates_generator.so:对‘boost::this_thread::hidden::sleep_until(timespec const&)’未定义的引用,My boost library version is 1.65.1,Can you give me some help?

sashaiw commented 2 years ago

I had a similar problem and was able to resolve it by adding the following include directive to src/gpg/plot.cpp:

#include <boost/thread/thread.hpp>

After this I still had some linking errors for Boost libraries:

/usr/bin/ld: libgrasp_candidates_generator.so: undefined reference to `boost::this_thread::interruption_point()'
/usr/bin/ld: libgrasp_candidates_generator.so: undefined reference to `boost::detail::get_current_thread_data()'

I resolved these errors by adding the following lines to my CMakeLists.txt:

# Boost
find_package(Boost REQUIRED COMPONENTS thread)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(-DBOOST_ALL_DYN_LINK)

# after add_executable() with the other target_link_libraries()
target_link_libraries(${PROJECT_NAME}_grasp_candidates_generator ${Boost_LIBRARIES})

I do not know if this is the correct solution to this problem nor have I tested the library yet but it allowed me to finish the build without errors. I am on Ubuntu 20.04 with Boost 1.71.

nuo-code commented 2 years ago

I am very glad to receive your reply, I have solved this mistake, my Ubuntu version is 18.04, I changed the Boost version to 1.53 is correct.This error was encountered earlier because the Boost version was too high.

------------------ 原始邮件 ------------------ 发件人: "atenpas/gpg" @.>; 发送时间: 2022年3月22日(星期二) 上午6:17 @.>; @.**@.>; 主题: Re: [atenpas/gpg] libgrasp_candidates_generator.so:对‘boost::this_thread::hidden::sleep_until(timespec const&)’未定义的引用 (Issue #14)

I was able to solve this problem by adding the following include directive to src/gpg/plot.cpp:

include <boost/thread/thread.hpp>

After this I still had some linking errors for Boost libraries: /usr/bin/ld: libgrasp_candidates_generator.so: undefined reference to boost::this_thread::interruption_point()' /usr/bin/ld: libgrasp_candidates_generator.so: undefined reference toboost::detail::get_current_thread_data()'
I resolved these errors by adding the following lines to my CMakeLists.txt:

Boost find_package(Boost REQUIRED COMPONENTS thread) include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIRS}) add_definitions(-DBOOST_ALL_DYN_LINK) # after add_executable() with the other target_link_libraries() target_link_libraries(${PROJECT_NAME}_grasp_candidates_generator ${Boost_LIBRARIES})

I do not know if this is the correct solution to this problem nor have I tested the library yet but it allowed me to finish the build without errors. I am on Ubuntu 20.04 with Boost 1.71.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Chan7348 commented 1 year ago

ye u r right thanks bro!!!

I had a similar problem and was able to resolve it by adding the following include directive to src/gpg/plot.cpp:

#include <boost/thread/thread.hpp>

After this I still had some linking errors for Boost libraries:

/usr/bin/ld: libgrasp_candidates_generator.so: undefined reference to `boost::this_thread::interruption_point()'
/usr/bin/ld: libgrasp_candidates_generator.so: undefined reference to `boost::detail::get_current_thread_data()'

I resolved these errors by adding the following lines to my CMakeLists.txt:

# Boost
find_package(Boost REQUIRED COMPONENTS thread)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(-DBOOST_ALL_DYN_LINK)

# after add_executable() with the other target_link_libraries()
target_link_libraries(${PROJECT_NAME}_grasp_candidates_generator ${Boost_LIBRARIES})

I do not know if this is the correct solution to this problem nor have I tested the library yet but it allowed me to finish the build without errors. I am on Ubuntu 20.04 with Boost 1.71.