不能包含boost文件系统标题 [英] can't include boost filesystem header
本文介绍了不能包含boost文件系统标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 N.cpp中
我需要使用 boost :: filesystem :: exists路径)
来检查路径是否有效。
为此,我包含< boost / filesystem.hpp>
我收到以下错误:
错误2错误LNK2005:public:enum boost :: filesystem :: file_type __cdecl boost :: filesystem :: file_status:已经在N.obj中定义了:type(void)const(?type @ file_status @ filesystem @ boost @@ QEBA?AW4file_type @ 23 @ XZ)D:\ MProject \ DA \ boost_filesystem-vc100-mt-gd- 1_53.lib(boost_filesystem-vc100-mt-gd-1_53.dll)DA
错误1错误LNK2005:public:__cdecl boost :: filesystem :: path ::〜path(void)( 1obpath @ filesystem @ boost @@ QEAA @ XZ)已经在N.obj中定义了D:\ MProject \DAboost_filesystem-vc100-mt-gd-1_53.lib(boost_filesystem-vc100-mt-gd-1_53.dll) DA
错误3错误LNK1104:无法打开文件'libboost_filesystem-vc100-mt-gd-1_53.lib'D:\MProject\DA\LINK DA
如果我不包含头文件,我会得到:
错误2错误C3861:存在':标识符未找到D:\ MProject \ DA\ThirdParty\N.cpp 108 1 DA
错误1错误C2653:'boost':不是类或名称空间名称D:\ MProject \DA\ThirdParty\N.cpp 108 1 DA
那么什么是正确的方法来使用boost :: filesystem :: exists,以便整个事情能够被编译?
N.cpp
#include< boost / filesystem.hpp>
.....
CHECK(boost :: filesystem :: exists(* i),std :: string(file).append(* i).append(does not exist ).c_str());
.....
解决方案
我通过添加到N.cpp解决了问题:
#ifndef BOOST_ALL_DYN_LINK
#define BOOST_ALL_DYN_LINK
#endif
#include< boost / filesystem.hpp>
I have a big project.
In N.cpp
I need to use boost::filesystem::exists(path)
to check if the path is valid.
For that, I include <boost/filesystem.hpp>
I get the following error:
Error 2 error LNK2005: "public: enum boost::filesystem::file_type __cdecl boost::filesystem::file_status::type(void)const " (?type@file_status@filesystem@boost@@QEBA?AW4file_type@23@XZ) already defined in N.obj D:\MProject\DA\boost_filesystem-vc100-mt-gd-1_53.lib(boost_filesystem-vc100-mt-gd-1_53.dll) DA
Error 1 error LNK2005: "public: __cdecl boost::filesystem::path::~path(void)" (??1path@filesystem@boost@@QEAA@XZ) already defined in N.obj D:\MProject\DAboost_filesystem-vc100-mt-gd-1_53.lib(boost_filesystem-vc100-mt-gd-1_53.dll) DA
Error 3 error LNK1104: cannot open file 'libboost_filesystem-vc100-mt-gd-1_53.lib' D:\MProject\DA\LINK DA
If I do not include the header file, I get :
Error 2 error C3861: 'exists': identifier not found D:\MProject\DA\ThirdParty\N.cpp 108 1 DA
Error 1 error C2653: 'boost' : is not a class or namespace name D:\MProject\DA\ThirdParty\N.cpp 108 1 DA
So What is the right way to use boost::filesystem::exists so that the whole thing would compile?
N.cpp
#include <boost/filesystem.hpp>
.....
CHECK( boost::filesystem::exists(*i), std::string("file ").append(*i).append(" does not exist").c_str() );
.....
解决方案
I solved the problem by adding to N.cpp:
#ifndef BOOST_ALL_DYN_LINK
# define BOOST_ALL_DYN_LINK
#endif
#include <boost/filesystem.hpp>
这篇关于不能包含boost文件系统标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文