问题
I wrote a program using the point cloud library (PCL). Now I want to use some of cgal's algorithms. I've managed to build a cgal class in isolation (all dependencies working etc.) but when I try and combine the two projects I get unresolved external symbol errors
So, what are my options for building a cgal project and accessing it (somehow) from my PCL project? I'd be passing a simple vector to the cgal project so in theory none of the specialist libraries have to interact with each other at all. I've tried building it into a static and dynamic library but as far as I know I still need to include all of the cgal dependencies when I do so -- this breaks things again.
More info with regards to unresolved externals:
I made a simple project (VS2010) using this CGAL example adding required dependencies using CMAKE: CGAL components (including QT), TAUCS, LAPACK, BLAS. The project builds happily. If I add references to the PCL library:
include_directories (${PCL_INCLUDE_DIRS})
link_directories (${PCL_LIBRARY_DIRS} )
add_definitions (${PCL_DEFINITIONS})
Now when I try to build I get four unresolved externals:
poisson.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void * __cdecl boost::detail::get_tss_data(void const *)" (__imp_?get_tss_data@detail@boost@@YAPAXPBX@Z) referenced in function "public: class CGAL::Lazy<class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> > >,class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Gmpq> >,class CGAL::Gmpq,class CGAL::Cartesian_converter<struct CGAL::Simple_cartesian<class CGAL::Gmpq>,struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> >,struct CGAL::NT_converter<class CGAL::Gmpq,class CGAL::Interval_nt<0> > > > * __thiscall boost::thread_specific_ptr<class CGAL::Lazy<class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> > >,class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Gmpq> >,class CGAL::Gmpq,class CGAL::Cartesian_converter<struct CGAL::Simple_cartesian<class CGAL::Gmpq>,struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> >,struct CGAL::NT_converter<class CGAL::Gmpq,class CGAL::Interval_nt<0> > > > >::get(void)const " (?get@?$thread_specific_ptr@V?$Lazy@V?$Point_3@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@CGAL@@@CGAL@@V?$Point_3@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@@2@VGmpq@2@V?$Cartesian_converter@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@2@U?$NT_converter@VGmpq@CGAL@@V?$Interval_nt@$0A@@2@@2@@2@@CGAL@@@boost@@QBEPAV?$Lazy@V?$Point_3@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@CGAL@@@CGAL@@V?$Point_3@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@@2@VGmpq@2@V?$Cartesian_converter@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@2@U?$NT_converter@VGmpq@CGAL@@V?$Interval_nt@$0A@@2@@2@@2@@CGAL@@XZ)
poisson.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::detail::set_tss_data(void const *,class boost::shared_ptr<struct boost::detail::tss_cleanup_function>,void *,bool)" (__imp_?set_tss_data@detail@boost@@YAXPBXV?$shared_ptr@Utss_cleanup_function@detail@boost@@@2@PAX_N@Z) referenced in function "public: void __thiscall boost::thread_specific_ptr<class CGAL::Lazy<class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> > >,class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Gmpq> >,class CGAL::Gmpq,class CGAL::Cartesian_converter<struct CGAL::Simple_cartesian<class CGAL::Gmpq>,struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> >,struct CGAL::NT_converter<class CGAL::Gmpq,class CGAL::Interval_nt<0> > > > >::reset(class CGAL::Lazy<class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> > >,class CGAL::Point_3<struct CGAL::Simple_cartesian<class CGAL::Gmpq> >,class CGAL::Gmpq,class CGAL::Cartesian_converter<struct CGAL::Simple_cartesian<class CGAL::Gmpq>,struct CGAL::Simple_cartesian<class CGAL::Interval_nt<0> >,struct CGAL::NT_converter<class CGAL::Gmpq,class CGAL::Interval_nt<0> > > > *)" (?reset@?$thread_specific_ptr@V?$Lazy@V?$Point_3@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@CGAL@@@CGAL@@V?$Point_3@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@@2@VGmpq@2@V?$Cartesian_converter@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@2@U?$NT_converter@VGmpq@CGAL@@V?$Interval_nt@$0A@@2@@2@@2@@CGAL@@@boost@@QAEXPAV?$Lazy@V?$Point_3@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@CGAL@@@CGAL@@V?$Point_3@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@@2@VGmpq@2@V?$Cartesian_converter@U?$Simple_cartesian@VGmpq@CGAL@@@CGAL@@U?$Simple_cartesian@V?$Interval_nt@$0A@@CGAL@@@2@U?$NT_converter@VGmpq@CGAL@@V?$Interval_nt@$0A@@2@@2@@2@@CGAL@@@Z)
poisson.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::system_category(void)" (__imp_?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "public: __thiscall boost::thread_exception::thread_exception(int,char const *)" (??0thread_exception@boost@@QAE@HPBD@Z)
poisson.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (__imp_?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)
I've been able to figure out most of these problems in the past but these blew my mind, hence why I wondered whether I could create two projects which interact but don't have to share libraries which aren't compatible.
回答1:
The OP solved his own problem in a comment section.
I've tried a number of different things including upgrading my boost version to 1.55 and referencing my CGAL code as a static library. I've finally managed to compile the code by rebuilding CGAL to use the static boost libraries (as PCL does).
来源:https://stackoverflow.com/questions/26266866/c-using-two-incompatible-libraries-together-what-are-the-options