使用boost :: filesystem时链接器错误?

 好人杨华_840 发布于 2023-02-04 15:13

我有以下代码:

#include 
#include 

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

当我构建时,我得到以下错误:

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,class std::allocator > &,class std::codecvt 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::allocator > >(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > &,class std::codecvt 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 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],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;

有人可以帮忙吗?当我使用boost :: algorithm,boost :: string和boost :: interprocess时,我的代码构建正常.

编辑:这是我在命令行上完成的链接如下所示:

/ 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

小智.. 11

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

1 个回答
  • 我在Visual Studio中构建了类似的未解析的外部.
    解决方案是将使用wchar_t设置为内置处理.

    2023-02-04 15:14 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有