I have the following libraries included from boost in eclipse cdt windows.
- libboost_filesystem-vc100-mt-1_51
- libboost_system-vc100-mt-1_51
From the top of the counsel output (bellow) they seem to be connecting fine. Yet I get the the following errors.
Counsel Output/Errors:
18:10:00 **** Incremental Build of configuration Debug for project Boost ****
Info: Internal Builder is used for build
g++ "-LC:\\Users\\Mike\\Desktop\\Lib\\boost_1_51_0\\stage\\lib" -o Boost.exe "src\\Boost.o" -llibboost_filesystem-vc100-mt-1_51 -llibboost_system-vc100-mt-1_51
src\Boost.o: In function `_static_initialization_and_destruction_0':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
src\Boost.o: In function `ZN5boost10filesystem9file_sizeERKNS0_4pathE':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
src\Boost.o: In function `path<char [9]>':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
src\Boost.o: In function `ZN5boost10filesystem11path_traits8dispatchISbIwSt11char_traitsIwESaIwEEEEvRKSsRT_RKSt7codecvtIwciE':
C:/Users/Mike/Desktop/Lib/boost_1_51_0/boost/filesystem/path_traits.hpp:174: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
collect2: ld returned 1 exit status
From which it seems that the system library is not connecting/linking properly.
My Code:
#include <boost/filesystem.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::filesystem;
file_size("test.txt");
return 0;
}
Am I missing something? Do I need to include something else?
each C++ compiler has its own rules and implementation of function name mangling( convert C++ function name to an ASM or C like function ).
for example MSVC convert boost::system::generic_category to ?generic_category@system@boost@@YAABVerror_category@12@XZ, but in this case you are using a DLL that built using MSVC2010(vc100) with eclipse g++ compiler that has a different rule for mangling names, so it expect something else that it can't find in the library and it generate a linker error.
as a general rule it is not legal to use a C++ object from a DLL that compiled from a compiler different than you use in your project, and even it is not legal to use a DLL that compiled with a previous version of your compiler and this is the reason that boost add vc100 to its DLL name to inform you that you should only use it with vc100( MSVC2010 )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With