Reputation: 875
I am on Windows and using a cross-platform project building for Linux in Visual Studio 2017 Community. I am trying to build my project but for some reason a library isn't being detected, or used correctly.
1>Linking objects
1>/home/ubuntu/projects/LinuxApplication/obj/x64/Debug/main.o: In function `__static_initialization_and_destruction_0(int, int)':
1>/usr/include/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
1>/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
1>/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
1>/home/ubuntu/projects/LinuxApplication/obj/x64/Debug/main.o: In function `boost::system::error_code::error_code()':
1>/usr/include/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
1>/home/ubuntu/projects/LinuxApplication/obj/x64/Debug/main.o: In function `boost::asio::error::get_system_category()':
1>/usr/include/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
1>collect2: error: ld returned 1 exit status
1>C:\Users\user\source\repos\LinuxApplication\obj\x64\Debug\main.o : error :
1>/usr/include/boost/system/error_code.hpp:221: undefined reference to `boost::system : error : generic_category()'
1>/usr/include/boost/system/error_code.hpp:222: undefined reference to `boost::system : error : generic_category()'
1>/usr/include/boost/system/error_code.hpp:223: undefined reference to `boost::system : error : system_category()'
1>C:\Users\user\source\repos\LinuxApplication\obj\x64\Debug\main.o: In function `boost::system::error_code: : error :
1>/usr/include/boost/system/error_code.hpp:322: undefined reference to `boost::system : error : system_category()'
1>C:\Users\user\source\repos\LinuxApplication\obj\x64\Debug\main.o: In function `boost::asio::error: : error :
1>/usr/include/boost/asio/error.hpp:230: undefined reference to `boost::system : error : system_category()'
1>collect2 : error : ld returned 1 exit status
1>Done building project "LinuxApplication.vcxproj" -- FAILED.
After reading some SO posts this seems to be because the library libboost_system
can't be found, however it is definitely present at /usr/lib/libboost_system.a
but for some reason the build isn't referencing this. I have tried adding the library to the linker in Visual Studio but it still does not seem to work.
If I compile the project manually on the Linux machine using g++ main.cpp -o main -lboost_system
the application builds correctly but this means I cannot debug the application so I'd like to get it working for the remote building.
Does anyone know how to link these libraries when using remote build from Visual Studio?
Upvotes: 1
Views: 1350
Reputation: 875
It seems from Visual Studio you need to specify the full path of the library into the linker. So for my case I had to add
/usr/lib/libboost_system.a
into the additional dependencies.
Upvotes: 1