我想构建一个使用Boost库的文件系统部分功能的项目,并且我不断收到链接错误。
我遵循Boost文档构建它,并且它成功构建,然后将所有lib文件从stage目录移动到C:/ boost/lib,并将hpp文件移动到C:/ boost/include。我正在使用Microsoft Visual Studio 2012速成版。我已经确保将属性页中的文件(libboost_filesystem-vc110-mt-1_54.lib和libboost_system-vc110-mt-1_54.lib)添加到需要链接的文件中(我也尝试过使用#pragma的明确)。我试了两个包含gd的.lib文件和那些不包含(调试和不用于调试的文件)。
我的问题是,我该如何解决这个问题?我是否构建了错误的文件?我有没有指定某种链接器属性错误?
这里的错误(我省略了一些,以保持它的短,如果需要的话我可以把他们):MSVS 2012 Express - 升压 - 链接器错误LNK2019
Error 1 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" ([email protected]@[email protected]@YAXXZ) C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
Error 2 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" ([email protected]@[email protected]@YAXXZ) C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
[...]
Error 5 error LNK2019: unresolved external symbol "public: class boost::filesystem::path __cdecl boost::filesystem::path::root_path(void)const " ([email protected]@[email protected]@@[email protected]) referenced in function main C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
Error 6 error LNK2019: unresolved external symbol "public: class boost::filesystem::path __cdecl boost::filesystem::path::root_name(void)const " ([email protected]@[email protected]@@[email protected]) referenced in function main C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
[...]
Error 18 error LNK1120: 17 unresolved externals C:\Visual Studio 2012 Projects\MMS_Solution\x64\Debug\MMS_Prj_FindFile.exe MMS_Prj_FindFile
这里的连接选项(如果需要别人我可以将它们添加):
链接器 - >常规
启用增量链接=是(/增量)
忽略导入库=否
寄存器输出=无
按照使用[R重定向=无
附加库目录= C:\ OpenSSL的\ lib中; C:\提升\ lib中
链接库的依赖=是
使用库的依赖输入=否
预防DLL的绑定=
链接 - >输入
所有这些都是除了
附加依赖= ssleay32.lib空白; libeay32.lib; WS2_32.LIB; libboost_system-vc110-MT-1_54.lib; libboost_filesystem-vc110-MT-1_54.lib;%(附加依赖)
下面的代码:
//Boost Includes
#include <boost/filesystem.hpp>
//Boost linking because visual studio won't link it (ugh)
#pragma comment (lib, "libboost_system-vc110-mt-gd-1_54.lib")
#pragma comment (lib, "libboost_filesystem-vc110-mt-gd-1_54.lib")
//Normal Includes
#include <iostream>
#include <string>
namespace bfs = boost::filesystem;
int main(int argc, char* argv[])
{
std::vector<std::string> foundPaths;
bfs::directory_iterator eit;
for(bfs::directory_iterator it("."); it != eit; it++)
{
if(!bfs::is_regular_file(it->status()))
continue;
bfs::path foundPath = it->path();
foundPaths.push_back("Root name: " + foundPath.root_name().string() + "\n" +
"Root dir : " + foundPath.root_directory().string() + "\n" +
"Root path: " + foundPath.root_path().string() + "\n" +
"Rel path: " + foundPath.relative_path().string() + "\n" +
"Prnt path: " + foundPath.parent_path().string() + "\n" +
"File name: " + foundPath.filename().string() + "\n" +
"Stem : " + foundPath.stem().string() + "\n" +
"Extension: " + foundPath.extension().string() + "\n");
}
for(std::vector<std::string>::iterator it = foundPaths.begin(); it != foundPaths.end(); ++it)
{
std::cout << *it << std::endl;
}
return 0;
}
请显示您的vs属性链接器选项。 – user1810087
我无法真正获得照片,因为任何图像托管网站在此处都被屏蔽。我试着添加一个列表。 – Coburn
你可以直接添加图片....是** libboost_system-vc110-MT-1_54.lib **和** libboost_filesystem-vc110-MT-1_54.lib ** * C中:\提升\ lib中*? – user1810087