簡體   English   中英

MSVS 2012 Express-Boost-鏈接器錯誤LNK2019

[英]MSVS 2012 Express - Boost - Linker error LNK2019

我正在嘗試建立一個使用Boost庫文件系統部分功能的項目,但不斷收到鏈接器錯誤。
我按照Boost文檔進行構建,並成功構建,然后將所有lib文件從舞台目錄移至C:/ boost / lib,將hpp文件移至C:/ boost / include。 我正在使用Microsoft Visual Studio 2012 Express Edition。 我已確保將屬性頁中的文件(libboost_filesystem-vc110-mt-1_54.lib和libboost_system-vc110-mt-1_54.lib)添加到需要鏈接的文件中(我也嘗試過使用#pragma明確)。 我嘗試了包含gd的.lib文件和沒有gd的.lib文件(調試文件和非調試文件)。

我的問題是,我該如何解決? 我生成的文件錯誤嗎? 我是否指定了某種鏈接器屬性錯誤?

這是錯誤(為了使內容簡短,我省略了一些錯誤,如果需要,我可以全部添加):

Error   1   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)  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)" (?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)  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 " (?root_path@path@filesystem@boost@@QEBA?AV123@XZ) 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 " (?root_name@path@filesystem@boost@@QEBA?AV123@XZ) 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

這是鏈接器選項(如果需要其他選項,我可以添加它們):

鏈接器->常規
啟用的增量鏈接=是(/ INCREMENTAL)
忽略導入庫=否
寄存器輸出=否
每用戶重定向=否
附加庫目錄= C:\\ openssl \\ lib; C:\\ boost \\ lib
鏈接庫依賴關系=是
使用庫依賴輸入=否
防止DLL綁定=

鏈接器->輸入
所有這些都是空白,除了
其他依賴關系= ssleay32.lib; libeay32.lib; Ws2_32.lib; libboost_system-vc110-mt-1_54.lib; libboost_filesystem-vc110-mt-1_54.lib;%(AdditionalDependencies)

這是代碼:

//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;
}

構建Boost時,如果要構建64位,請確保使用參數“ address-model = 64”。
它在文檔中說,如果正確配置了編譯器,但顯然我的編譯器不是我的編譯器,則編譯器應選擇正確的編譯器;當我想要64位二進制文​​件時,它正在構建32位二進制文​​件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM