2011-08-29 120 views
4

我在instructions here之后下载并构建了Windows 7(64位)上的boost库(版本1.47.0)。Boost :: FileSystem链接问题

现在,当我想要使用Boost::Filesystem库时,我可以包含头文件而没有问题,它编译我的代码文件。链接时出现问题。我得到以下错误;

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 *)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "bool __cdecl boost::filesystem3::exists(class boost::filesystem3::path const &)" ([email protected]@[email protected]@[email protected]@@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)" ([email protected]@[email protected]@@[email protected][email protected]@@XZ) referenced in function "public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem3::path::codecvt(void)" ([email protected]@[email protected]@@[email protected][email protected]@@XZ) 

(其中包括)

这可能是值得一提的是,当我第一次尝试建立它说,它无法找到的.lib文件libboost_filesystem-vc100-mt-1_47.lib项目。我没有具体说明它需要这个文件,所以不知道它是如何计算出来的?无论哪种方式,我指出链接器正确的目录,然后它给出了上述错误。

有谁知道如何解决这个问题?谢谢。

编辑:我使用VS2010工具链通过Eclipse CDT来构建系统。完整的编译命令是

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> 

和连接器命令

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> 
+0

你可以显示一个最小的例子,重现你有错误的代码? – CharlesB

+0

你的项目目标系统是什么?你是否用相同的位数构建Boost:32位用于Win32,64位用于64位? –

+1

至于你的侧面问题,boost会自动添加一个'pragma'语句来告诉它所需的链接器.lib – CharlesB

回答

2

重建与地址模型Boost库= 64 B2命令行开关。这建立了64位库。

+0

这样做的窍门。谢谢。 – Dan

0

如果你在Linux和这篇文章后发生寻找解决的解决方法是(至少在Ubuntu 12.10),以安装提高文件系统的开发包:

命令和apt-get安装的libboost文件系统-dev

安装正确的库链接到和所有作品。