sick_scan_base
sick_scan_base copied to clipboard
Redefinition problems when trying to use 'sick_scan_base' for other libs.
Description:
I was trying to encapsulate sick_scan_base for my own lib which uses SickTim561. I modified 'CMakeLists.txt' for compilation and installing and everything works fine. However, when i tried '#include <sick_scan/sick_generic_laser.h>', some redefinition errors happen.
Error messages:
1>libboost_system-vc141-mt-x32-1_68.lib(error_code.obj) : error LNK2005: "public: virtual class boost::system::error_condition __thiscall boost::system::detail::system_error_category::default_error_condition(int)const " (?default_error_condition@system_error_category@detail@system@boost@@UBE?AVerror_condition@34@H@Z) already defined in sick_scan.lib(rossimu.obj)
1>libboost_system-vc141-mt-x32-1_68.lib(error_code.obj) : error LNK2005: "public: virtual class std::basic_string<char,struct std::char_traits
1>libboost_system-vc141-mt-x32-1_68.lib(error_code.obj) : error LNK2005: "public: virtual class std::basic_string<char,struct std::char_traits
1>D:\visionnav-libraries\ForkingPerceptionModule2D\out\build32\bin\RelWithDebInfo\LaserDriver.dll : fatal error LNK1169: one or more multiply defined symbols found
Trials:
I tried everything I could come up, including adding "#ifndef #define #endif", but none helped. And I looked up the source code and found some functions may be the source of problems. The functions are like:
void ros::init(int &, char * *, class std::basic_string<char, struct std::char_traits
Thanks for reporting. Since all messages are linker errors, I guess that both sick_scan.lib and other libs/executables are linked against boost libraries. This way symbols defined in the boost library may be defined in other libs, too. If possible, try to link boost libraries only once in your executable (i.e. do not link libraries against boost except the main executable).
Alternatively, you can link with option /FORCE, which forces a link to complete even with unresolved symbols or symbols defined more than once.
Another alternative is to switch to sick_scan_xd, see https://github.com/SICKAG/sick_scan_xd for details. This driver has no boost dependencies and supports both Linux and Windows with or without ROS.
Visual Studio 2019 is recommended for the Windows build. If you're using Visual Studio 2017 (which "libboost_system-vc141" suggests), try upgrading to Visual Studio 2019.
Visual Studio 2019 is recommended for the Windows build. If you're using Visual Studio 2017 (which "libboost_system-vc141" suggests), try upgrading to Visual Studio 2019.
Thank you for your replay. I am using VS 2019 and this "libboost_system-vc141" is a prebuilt lib which is installed from PCL(PCL itself has a boost-1.68 library build by VS 2017.) In fact, when building sick_scan_base
, I linked boost-1.68-vc141, and boost-1.78-vc142 for my own lib.
Anyway, I'll try using boost-1.78 built by VS2019 and see if the problem will be solved.
It works. I applied both libs(personal lib and sick_scan_base) with boost 1.68, and the exact problem seems to be solved.