包括Boost文件系统头 [英] Including the Boost filesystem header
本文介绍了包括Boost文件系统头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个大项目.
在N.cpp
中,我需要使用boost::filesystem::exists(path)
来检查路径是否有效.
In N.cpp
I need to use boost::filesystem::exists(path)
to check if the path is valid.
为此,我加入了<boost/filesystem.hpp>
我收到以下错误:
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
什么是使用boost::filesystem::exists
以便可以编译整个内容的正确方法?
What is the right way to use boost::filesystem::exists
so that the whole thing would compile?
#include <boost/filesystem.hpp>
.....
CHECK( boost::filesystem::exists(*i), std::string("file ").append(*i).append(" does not exist").c_str() );
.....
推荐答案
我通过添加到N.cpp来解决了这个问题:
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屋!
查看全文