0

I wrote a library that uses PCL and boost in C++. It is building perfectly. When I tried to make a wrapper for it using C++/CLR I got a lot of unresolved errors. Firstly, why Visual Studio is re-building my library again when building the wrapper? Secondly, why I got the following unresolved errors?:

Error   LNK2005 "protected: virtual void __cdecl pcl::Grabber::signalsChanged(void)" (?signalsChanged@Grabber@pcl@@MEAAXXZ) already defined in pcl_io_debug.lib(pcl_io_debug.dll)
Error   LNK2005 "protected: virtual void __cdecl pcl::Grabber::signalsChanged(void)" (?signalsChanged@Grabber@pcl@@MEAAXXZ) already defined in pcl_io_debug.lib(pcl_io_debug.dll)
Error   LNK2001 unresolved external symbol "public: virtual void __cdecl pcl::visualization::PCLVisualizer::FPSCallback::Execute(class vtkObject *,unsigned long,void *)" (?Execute@FPSCallback@PCLVisualizer@visualization@pcl@@UEAAXPEAVvtkObject@@KPEAX@Z)
Error   LNK2019 unresolved external symbol deflate referenced in function "protected: int __cdecl boost::iostreams::detail::zlib_base::xdeflate(int)" (?xdeflate@zlib_base@detail@iostreams@boost@@IEAAHH@Z)
Error   LNK2019 unresolved external symbol deflateEnd referenced in function "protected: void __cdecl boost::iostreams::detail::zlib_base::reset(bool,bool)" (?reset@zlib_base@detail@iostreams@boost@@IEAAX_N0@Z)
Error   LNK2019 unresolved external symbol inflate referenced in function "protected: int __cdecl boost::iostreams::detail::zlib_base::xinflate(int)" (?xinflate@zlib_base@detail@iostreams@boost@@IEAAHH@Z)
Error   LNK2019 unresolved external symbol inflateEnd referenced in function "protected: void __cdecl boost::iostreams::detail::zlib_base::reset(bool,bool)" (?reset@zlib_base@detail@iostreams@boost@@IEAAX_N0@Z)
Error   LNK2019 unresolved external symbol deflateReset referenced in function "protected: void __cdecl boost::iostreams::detail::zlib_base::reset(bool,bool)" (?reset@zlib_base@detail@iostreams@boost@@IEAAX_N0@Z)
Error   LNK2019 unresolved external symbol inflateReset referenced in function "protected: void __cdecl boost::iostreams::detail::zlib_base::reset(bool,bool)" (?reset@zlib_base@detail@iostreams@boost@@IEAAX_N0@Z)
Error   LNK2019 unresolved external symbol crc32 referenced in function "protected: void __cdecl boost::iostreams::detail::zlib_base::after(char const * &,char * &,bool)" (?after@zlib_base@detail@iostreams@boost@@IEAAXAEAPEBDAEAPEAD_N@Z)
Error   LNK2019 unresolved external symbol deflateInit2_ referenced in function "private: void __cdecl boost::iostreams::detail::zlib_base::do_init(struct boost::iostreams::zlib_params const &,bool,void * (__cdecl*)(void *,unsigned int,unsigned int),void (__cdecl*)(void *,void *),void *)" (?do_init@zlib_base@detail@iostreams@boost@@AEAAXAEBUzlib_params@34@_NP6APEAXPEAXII@ZP6AX22@Z2@Z)
Error   LNK2019 unresolved external symbol inflateInit2_ referenced in function "private: void __cdecl boost::iostreams::detail::zlib_base::do_init(struct boost::iostreams::zlib_params const &,bool,void * (__cdecl*)(void *,unsigned int,unsigned int),void (__cdecl*)(void *,void *),void *)" (?do_init@zlib_base@detail@iostreams@boost@@AEAAXAEBUzlib_params@34@_NP6APEAXPEAXII@ZP6AX22@Z2@Z)
sehe
  • 374,641
  • 47
  • 450
  • 633
Ahmad Mhaish
  • 111
  • 1
  • 8

2 Answers2

1

C++-CLI is a different language; it compiles to an entirely different target (some .NET runtime version/architecture), which is both why it builds again and why you need to configure the link dependencies for those target configurations.

I'd personally keep all native dependencies inside a native DLL and have a narrow interface implemented in a mixed-mode assembly. That way you can summarize the dependencies of the mixed-mode assembly as being the one native DLL that bundles any other native dependencies.

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Actually I am not including any native dependencies in my wrapper project. In wrapper I am just creating an object from a class I have created in native dll and calling two functions from that class. So why from the first place these errors appears to me. Do you have any clue? – Ahmad Mhaish Nov 09 '17 at 12:29
  • The error messages speak clearly: you depend on libz2, PCL visualization and grabber. These are clearly native dependencies and missing. You can always per-use [this FAQ entry](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) to hunt for the source – sehe Nov 09 '17 at 12:31
0

Actually I have just used BOOST_IOSTREAMS_NO_LIB, and that fixed most of the problems. So it appeared to me that there is a problem in bzip2 filters in windows cause it should be disabled by default, and that disable them mostly. For other problem related to visualizer I found out the answer here

Ahmad Mhaish
  • 111
  • 1
  • 8