Scanning dependencies of target main
[ 50%] Building CXX object CMakeFiles/main.dir/tensor_test.cpp.o
[100%] Linking CXX executable main
CMakeFiles/main.dir/tensor_test.cpp.o: In function `main':
tensor_test.cpp:(.text+0x6b): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
When removing the ${TORCH_LIBRARIES} variable from target_link_libraries linking works correctly.
The same issue arises with other shared libraries.
I guess this is a similar issue to the one reported here:
I am on Ubuntu18.04 and I am using libtorch 1.0.0.dev20181022, boost 1.65.1
thank you for trying it out.
The problem seems related to the Ubuntu version.
I confirm that the build works with 14.04, but it fails on Ubuntu 16.04 and 18.04.
I particular, I moved the object file from the working 14.04 machine to the 16.04 machine and the link stage failed.
I have used g++ 5.5.0 20171010 on both.
(The suggestion of duplicating the target_link_libraries function does not make a difference)
I think that this can be related to the C++11 ABI as well, see this comment I posted: Issues linking with libtorch (C++11 ABI?), Iām facing similar issues with other libraries. The issue seems that libtorch is adding this definition to compilation _GLIBCXX_USE_CXX11_ABI=0, which forces GCC to use old C++11 ABI, and this is incompatible with your boost dependency, hence the error youāre getting, because the std::string was changed between old and new C++11 ABI.
It will give rise to āundefined reference to `cv::imread(std::string const&, int)āā
And when I removed ātarget_link_libraries(simnet ā${TORCH_LIBRARIES}ā)ā and the build process succeeded.