boost :: filesystem和VC ++ 2010中的特定LNK2001错误

时间:2013-11-18 20:46:45

标签: c++ boost visual-studio-2010 lnk2001

我对此感到困惑。

我有一些跨平台代码,我试图用Win7 x64编译。 该代码使用Boost 1.54.0,特别是boost :: filesystem库。

我尝试将字符串分配给filesystem :: path时,除了少量函数调用外,绝大多数代码都会编译。

例如,如果我要做一些简单的事情:

string path = (char *)"/This/Is/A/Fake/Path";
filesystem::path boostpath = path;

我在链接阶段得到以下内容:

LNK2001: unresolved external symbol "void __cdecl boost::filesystem::path_traits::convert(unsigned short const *,unsigned short const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<unsigned short,char,int> const &)" (?convert@path_traits@filesystem@boost@@$$FYAXPEBG0AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$codecvt@GDH@5@@Z)

我不知道造成这种情况的原因。其他boost库,(和Filesystem调用)工作得很好! 我能想到的唯一一件事就是广角和Windows都有。搜索stackoverflow并没有找到我能找到的任何东西。链接错误本身似乎与字符串转换有关。

当然,这适用于Linux / MacOSX。

提前致谢!

鲍勃。

1 个答案:

答案 0 :(得分:1)

我终于得到了使用/ Zc:wchar_t-开关的提升。这涉及编辑“msvc.jam”文件。此文件位于您的boost源文件夹中。

路径是: your-boost-path /bo_1_1_54_0/tools/build/v2/tools/msvc.jam

我搜索了wchar_t,它显示了 / Zc:wchar_t 标志。 我通过将其更改为 / Zc:wchar_t - 来更改标记。

更新的行如下所示:

 toolset.flags $(toolset).compile CFLAGS $(conditions) : /Zc:forScope /Zc:wchar_t- ;

然后我使用以下命令行编译了boost。 (我根据自己的需要专门使用了这些标志。)

bjam --toolset=msvc-10.0 architecture=x86 threading=multi link=static address-model=64 --build-type=complete install --prefix=C:\local\boost

编译完成后,我给了我的项目一个镜头,它似乎工作! 我还没有做过任何严肃的测试,但它似乎在编译。

注意:切换wchar_t标志会导致很多的编译器警告,以及一些失败。虽然我没有使用所有提升优惠的套餐,但我希望我需要的套餐还可以。

鲍勃..

相关问题