Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用boost::filesystem失败,原因是_fchmodat“;在mac上_C++_Macos_Boost_Filesystems - Fatal编程技术网

C++ 使用boost::filesystem失败,原因是_fchmodat“;在mac上

C++ 使用boost::filesystem失败,原因是_fchmodat“;在mac上,c++,macos,boost,filesystems,C++,Macos,Boost,Filesystems,我想使用boost::filesystem的一些函数 我可以包括boost/filesystem.hpp和boost/filesystem/path.hpp而没有任何问题,但只要我使用一些特定函数,如boost::filesystem::current_path()或boost::filesystem::initial_path()我就会得到以下编译器错误: Undefined symbols for architecture x86_64: "_fchmodat", referenced fr

我想使用
boost::filesystem
的一些函数

我可以包括
boost/filesystem.hpp
boost/filesystem/path.hpp
而没有任何问题,但只要我使用一些特定函数,如
boost::filesystem::current_path()
boost::filesystem::initial_path()
我就会得到以下编译器错误:

Undefined symbols for architecture x86_64:
"_fchmodat", referenced from:
boost::filesystem::detail::permissions(boost::filesystem::path const&,
boost::filesystem::perms, boost::system::error_code*) in 
libboost_filesystem.a(operations.o)
ld: symbol(s) not found for architecture x86_64
我正在链接
-lboost系统
-lboost文件系统
,并使用
-std=c++0x
作为编译器标记

boost的版本是通过自制软件安装的1.56.0


编辑:我也使用boost 1.57.0进行了尝试,但错误相同。

显然Qt Creator与
libboost system.a
libboost filesystem.a
相关联。但在MacOSX上,它应该链接到
libboost system.dylib
libboost filesystem.dylib


通过使用
LIBS+=“path/libboost system.dylib”
显式链接
.dylib
-库,我在.pro文件中对此进行了更改。这解决了问题。

我觉得这像是一个升级错误。静态链接和动态链接这些库之间应该没有区别。但是没有解释发生了什么


请注意,截至本文撰写之时的当前版本Boost 1.58中仍然存在此问题。

更新:这将在即将发布的Boost 1.60中修复。我的修复已提交到。您还可以将应用于早期版本的Boost

原始答案: 这是Boost.Filesystem中的一个bug,被跟踪为。我遇到了同样的问题,并开发了一个补丁,我附加到这个bug上


如果你能将补丁应用到Boost.Filesystem源文件的副本上,并报告它现在是否适合你,那就太好了。

我刚刚解决了这个问题。出于某种原因,它与libboost system.a相关联,而不是libboost-system.dylib,libboost-filesystem也是如此。也许你可以通过自我回答让这个问题对其他人有价值。如果动态库和静态库都是使用不同版本的boost(有此问题的版本和没有此问题的版本)构建的,那么更改链接选项将不会解决根本问题。