【发布时间】:2012-03-02 04:22:27
【问题描述】:
我正在尝试根据 CMake 的提升来编译 c++ 软件。使用相同的源代码和 CMakeLists.txt 文件,我成功使用了自己的笔记本电脑(带有 boost1.42 的 ubuntu 11),但是我在研究组(顺便说一句)中使用我的工作站(带有 boost 1.41 的 RHEL6.2)收到以下错误消息,boost1.41应该够用了):
main/main.cpp: In function ‘path
make_path(const std::string&)’:
main/main.cpp:50: error: invalid
conversion from ‘bool (*)(const std::string&)’ to ‘void*’
main/main.cpp:50: error:
initializing argument 2 of ‘boost::filesystem3::path::path(const Source&,
typename
boost::enable_if<boost::filesystem3::path_traits::is_pathable<typename
boost::decay<Source>::type>, void>::type*) [with Source =
std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’
main/main.cpp: In function ‘int
main(int, char**)’:
main/main.cpp:664: error: ‘class
path’ has no member named ‘native_file_string’
main/main.cpp:676: error: ‘class
path’ has no member named ‘native_file_string’
make[2]: *** [main/CMakeFiles/vina_main.dir/main.cpp.o] Error 1
make[1]: *** [main/CMakeFiles/vina_main.dir/all] Error 2
make: *** [all] Error 2
我不太了解错误消息,也不知道如何修复它。谁能帮帮我?
========================更新======================= ==
感谢您的帮助,上述错误消息已得到修复,但我仍然收到错误消息,表明我的可执行文件和 boost 库之间的链接失败。我确实通过'target_link_libraries(vvv_main vvv ${Boost_LIBRARIES})'在CMakeLists.txt中链接它。错误信息是这样的:
CMakeFiles/vvv_main.dir/main.cpp.o: In function '__static_initialization_and_destruction_0':
/usr/local/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/local/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
.......
我在这里阅读了其他相关帖子,但仍然不知道如何解决我的问题。谢谢!
【问题讨论】:
-
你能给我们看看 main.cpp 的第 50 行吗?也许还有一些关于这条线的背景?
-
另外,在第 664 行,您似乎在调用一个不存在的方法。我知道 boost::filesystem v3 破坏了 v2 的许多东西,所以检查被删除的函数。
-
在
main.cpp的第50 行中,您正在实例化一个boost::fileystem3::path对象。您传递给构造函数的第二个参数是什么? -
您确定这是 1.41 版吗?因为 v3 只是从 Boost 1.46 开始的默认设置。另一件事是
path::native_file_string已被弃用并且(我认为)已经有一段时间了。 Boost 是否实际提供不推荐使用的位由#define控制;也许它在您的两个系统上的定义不同。 -
@wilhelmtell 谢谢。第 50 行是 :' return path(str, boost::filesystem::native); '。问题是由于默认的 Boost 文件系统版本。但是现在我在将可执行文件与 boost 库链接时遇到了一些问题。