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 ファイルとそうでないファイル (デバッグ用のものとデバッグ用ではないもの) の両方を試しました。
私の質問は、どうすればこれを修正できますか? ファイルを間違ってビルドしましたか? ある種のリンカー プロパティを間違って指定しましたか?
エラーは次のとおりです(短くするために一部を省略しました。必要に応じてすべて追加できます)。
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
リンカー オプションは次のとおりです (他に必要な場合は追加できます)。
Linker -> General
Enabled Incremental Linking = Yes (/INCREMENTAL)
Ignore Import LIBrary = No
Register Output = No
Per-user Redirection = No
追加のライブラリ ディレクトリ = C:\openssl\lib;C:\boost\lib
Link Library Dependencies = Yes
ライブラリの依存関係を使用する 入力 = いいえ
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;
}