使用boost :: filesystem时的链接器错误? [英] Linker errors when using boost::filesystem?

查看:425
本文介绍了使用boost :: filesystem时的链接器错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

#include <iostream>
#include <boost\filesystem.hpp>

int main(){
    const char* file_path = "my_path";
    std::cout << boost::filesystem::file_size(file_path) << std::endl;
}

当我构建时,出现以下错误:

and when I build I get the following errors:

1>Main.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat@system@boost@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat@system@boost@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert@path_traits@filesystem@boost@@YAXPEBD0AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEBV?$codecvt@_WDH@5@@Z) referenced in function "void __cdecl boost::filesystem::path_traits::dispatch<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &)" (??$dispatch@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@path_traits@filesystem@boost@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@4@AEBV?$codecvt@_WDH@4@@Z)
1>Main.obj : error LNK2019: unresolved external symbol "public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem::path::codecvt(void)" (?codecvt@path@filesystem@boost@@SAAEBV?$codecvt@_WDH@std@@XZ) referenced in function "public: __cdecl boost::filesystem::path::path<char const [1]>(char const (&)[1],void *)" (??$?0$$BY00$$CBD@path@filesystem@boost@@QEAA@AEAY00$$CBDPEAX@Z)
1>Main.obj : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl boost::filesystem::detail::file_size(class boost::filesystem::path const &,class boost::system::error_code *)" (?file_size@detail@filesystem@boost@@YA_KAEBVpath@23@PEAVerror_code@system@3@@Z) referenced in function "unsigned __int64 __cdecl boost::filesystem::file_size(class boost::filesystem::path const &)" (?file_size@filesystem@boost@@YA_KAEBVpath@12@@Z)

我正在使用Visual Studio,并且已为链接器设置其他库路径以包含"C:\Program Files\Boost\boost_1_54_0\stage\lib;".我还设置了包含路径以查看C:\Program Files\Boost\boost_1_54_0;

I am using Visual Studio and I have set the additional library path for my linker to include "C:\Program Files\Boost\boost_1_54_0\stage\lib;". I also have set the include path to look at C:\Program Files\Boost\boost_1_54_0;

任何人都可以帮忙吗? 当我使用boost :: algorithm,boost :: string和boost :: interprocess 时,我的代码构建良好.

Can anyone please help? My code builds fine when I use boost::algorithm, boost::string and boost::interprocess.

这是我在命令行上进行链接时的样子:

this is what my linking if done on the command-line looks like:

/OUT:"my_file_path"/MANIFEST/NXCOMPAT/PDB:"my_file_path" /DYNAMICBASE"kernel32.lib""user32.lib""gdi32.lib""winspool.lib" "comdlg32.lib""advapi32.lib""shell32.lib""ole32.lib""oleaut32.lib" "uuid.lib""odbc32.lib""odbccp32.lib"/DEBUG/MACHINE:X64 /INCREMENTAL/PGD:"my_file_path"/MANIFESTUAC:"level ='asInvoker' uiAccess ='false'"/ManifestFile:" my_file_path"/ERRORREPORT:PROMPT /NOLOGO/LIBPATH:"C:\ Program Files \ Boost \ boost_1_54_0 \ stage \ lib" /TLBID:1

/OUT:"my_file_path" /MANIFEST /NXCOMPAT /PDB:"my_file_path" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X64 /INCREMENTAL /PGD:"my_file_path" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"my_file_path" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Program Files\Boost\boost_1_54_0\stage\lib" /TLBID:1

推荐答案

我在Visual Studio中构建了类似的未解决的外部组件.
解决方案是将使用wchar_t设置为内置.

I had similar unresolved externals building in Visual Studio.
The solution was to set use wchar_t to be treated as built-in.

这篇关于使用boost :: filesystem时的链接器错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆