C++ boost错误:在‘&燃气轮机’;代币

C++ boost错误:在‘&燃气轮机’;代币,c++,boost,boost-filesystem,C++,Boost,Boost Filesystem,以下代码打印处理当前工作路径。使用Boost1.52,在VisualStudio2010中运行 #include <iostream> #include <string> #include "boost/algorithm/string.hpp" #include "boost/filesystem/path.hpp" #include "boost/filesystem/operations.hpp" #include "boost/format.hpp" int m

以下代码打印处理当前工作路径。使用Boost1.52,在VisualStudio2010中运行

#include <iostream>
#include <string>
#include "boost/algorithm/string.hpp"
#include "boost/filesystem/path.hpp"
#include "boost/filesystem/operations.hpp"
#include "boost/format.hpp"

int main(int argc, const char* argv[]) {
        std::string p = boost::filesystem::initial_path<boost::filesystem::path>().string();
        std::cout << p;
        return 0;
}
我在stackoverflow中搜索了带有相同错误的帖子,但不知道如何修复它。任何帮助都将不胜感激

g++版本:

Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)
-------------------问题解决了------------------------

我解决了这个问题。原因是,我更改了boost头文件目录名,同时忘记了更改makefile中的include路径

稍后,我再次输入错误:

boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()
这是因为我从其他地方复制了编译好的boost库,因为某些原因,它与我的linux不兼容。我重新编译了boost,最终所有的工作都完成了


感谢洛夫博士、伊戈尔、莱文利和卡夫,感谢他的帮助

考虑将C++语言标记添加到此,这样更多的人会读取Itt,好像这个函数被弃用一样。您在Windows和Linux上有相同的boost版本吗?boost版本与1.52相同您可能没有在Windows上使用1.52。正如您所看到的和,initial_path的v2版本有一个模板参数,而v3版本没有。(Boost 1.49.0是提供v2的最后一个版本)。
boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()