У меня есть следующий код:Ошибки компоновщика при использовании 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;
}
и когда я строю я получаю следующие ошибки:
1>Main.obj : 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)
1>Main.obj : 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)
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 &)" ([email protected][email protected]@[email protected]@[email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@[email protected][email protected]@@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 &)" ([email protected][email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected][email protected]@@[email protected][email protected]@@[email protected][email protected][email protected]@@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)" ([email protected]@[email protected]@@[email protected][email protected]@@XZ) referenced in function "public: __cdecl boost::filesystem::path::path<char const [1]>(char const (&)[1],void *)" ([email protected]@[email protected]@@[email protected][email protected])
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 *)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@Z) referenced in function "unsigned __int64 __cdecl boost::filesystem::file_size(class boost::filesystem::path const &)" ([email protected]@[email protected]@[email protected]@@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.
EDIT: это то, что мой сшивание, если сделано в командной строке выглядит следующим образом:
/OUT: "my_file_path"/МАНИФЕСТ/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 \ этап \ Lib " /TLBID: 1
BTV, 'Главный()' 'всегда возвращает int' в соответствии со стандартом C++. –
http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html в разделе «Ссылка изнутри Visual Studio IDE» они устанавливают только дополнительный путь библиотеки для компоновщика ....? – user997112
@ user007112: Я не знал о функции автоматической привязки. Возможно, вам нужно будет перестроить ... Были ли какие-либо другие сообщения об ошибках, например, о не найденных библиотеках или неправильных символах? –