0

I'm trying to build boost asio timer sample within Eclipse on Windows and I occurred following errors:

g++ "-LC:\\Boost\\lib" -o boost_sync_timer.exe "src\\boost_sync_timer.o" -lws2_32 -llibboost_system-vc140-mt-1_61 -llibboost_system-vc140-mt-s-1_61 -llibboost_system-vc140-sgd-1_61 -llibboost_system-vc140-s-1_61 -llibboost_system-vc140-mt-sgd-1_61 -llibboost_system-vc140-mt-gd-1_61 -lboost_system-vc140-mt-1_61 -lboost_system-vc140-mt-gd-1_61 
src\boost_sync_timer.o: In function `_static_initialization_and_destruction_0':
C:/Boost/include/boost-1_61/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
C:/Boost/include/boost-1_61/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/Boost/include/boost-1_61/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
src\boost_sync_timer.o: In function `ZN5boost6system10error_codeC1Ev':
C:/Boost/include/boost-1_61/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
src\boost_sync_timer.o: In function `ZN5boost4asio5error19get_system_categoryEv':
C:/Boost/include/boost-1_61/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status

There are already lots of similar issues posted but most of them are on Linux OS.(like undefined reference to boost::system::system_category() when compiling, -lboost_system should fix)

Although this post How to build boost::asio? is a similar issue, but its solution seems strange. My boost library is build with msvc-14.0(bjam --toolset=msvc-14.0 --build-type=complete architecture=x86 address-model=64 install). Should there be no difference no matter what compler to use while installing boost library?

As you can see, I import all "system" related libraries under "C:\Boost\lib", but there are still above errors! Any help? Thanks a lot!

Community
  • 1
  • 1
maple
  • 15
  • 5
  • You built the `boost` library using `Visual Studio` and you are try to link to it with `GCC`. The libraries are NOT compatible. You need to build `boost` for `gcc` on `windows` and link to that version instead. Or, you could just build the sample with `Visual Studio`... – kenba Jul 05 '16 at 05:23
  • It turns OK when I build my codes with the boost libraries which build with mingw! Thank you very much for your help! But I can't help wondering is there a better way to make a libraries could be used both for mingw(Eclipse) & VC? Is that necessary to keep multiple libraries if I had various develop environment on Windows? – maple Jul 06 '16 at 07:05
  • BTW, do you know how to import all libraries under a specific folder within Eclipse? Add them one by one under "Labraries(-l)" column seems not a good way............ – maple Jul 06 '16 at 07:09

0 Answers0