开发者

Boost::FileSystem Linking Problem

I downloaded and built the boost libraries (version 1.47.0) on Windows 7 (64bit) following the instructions here.

Now when I want to use the Boost::Filesystem library I can include the header file without issue and it compiles my code file. The problem arises at linking. I get the following errors;

main.obj : error LNK2019: unresolved external symbol "class boost::filesystem3::file_status __cdecl boost::filesystem3::detail::status(class boost::filesystem3::path const &,class boost::system::error_code *)" (?status@detail@filesystem3@boost@@YA?AVfile_status@23@AEBVpath@23@PEAVerror_code@system@3@@Z) referenced in function "bool __cdecl boost::filesystem3::exists(class boost::filesystem3::path const &)" 开发者_如何学Python(?exists@filesystem3@boost@@YA_NAEBVpath@12@@Z)
main.obj : error LNK2019: unresolved external symbol "private: static class std::codecvt<wchar_t,char,int> const * & __cdecl boost::filesystem3::path::wchar_t_codecvt_facet(void)" (?wchar_t_codecvt_facet@path@filesystem3@boost@@CAAEAPEBV?$codecvt@_WDH@std@@XZ) referenced in function "public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem3::path::codecvt(void)" (?codecvt@path@filesystem3@boost@@SAAEBV?$codecvt@_WDH@std@@XZ)

(amongst others)

It might be worth noting that when I first tried to build the project it said it couldn't find the .lib file libboost_filesystem-vc100-mt-1_47.lib. I hadn't specifically told it it needed that file so not sure how it figured that out? Either way I pointed the linker to the correct directory and then it gave the above errors.

Does anybody know how to fix this problem? Thanks.

Edit: I'm using VS2010 toolchain through eclipse CDT to build the system. The complete compile command is

cl /c /EHs /MD /Zi /I"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" /I"C:\boost_1_47_0" /nologo <SOURCE_FILE>

and the linker command

link /debug /nologo /libpath:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64 /libpath:C:\boost_1_47_0\stage\lib /libpath:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64 /OUT:<EXE_NAME> <OBJECT_FILES>


Rebuild the Boost library with address-model=64 b2 command line switch. This builds 64 bit libraries.


If you're on linux and happen upon this article looking for the fix the fix is (at least on ubuntu 12.10) to install the development package for boost filesystem:

sudo apt-get install libboost-filesystem-dev

That installs the correct libraries for linking to and all works well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜