我一直在尝试编译图像剪辑器不成功,我已经安装了opencv和boost和build-essential(gcc版本是4.6.3)。
问题出现在修改 Makefile 时,我需要根据我的系统替换两个变量。
原来这些变量是这样的:
CFLAGS = `pkg-config --cflags opencv` -I ~/usr/include/boost-1_36 -I.
LFLAGS = `pkg-config --libs opencv` -L ~/usr/lib -lboost_system-gcc41-mt -lboost_filesystem-gcc41-mt
我通过 synaptic 安装了 boost(已安装libboost-all-dev
),如何找到boost
和 的安装路径lboost_system-gcc41-mt
?
编辑:经过进一步研究后,我的 Makefile 是:
CFLAGS = `pkg-config --cflags opencv` -I /usr/include/boost -I.
LFLAGS = `pkg-config --libs opencv` -L /usr/lib -lboost_system-mt -lboost_filesystem-mt
现在我收到这个错误:
In file included from imageclipper.cpp:43:0:
filesystem.h: In function ‘std::string fs::realpath(const string&)’:
filesystem.h:60:23: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h: In function ‘std::string fs::dirname(const string&)’:
filesystem.h:66:37: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h: In function ‘std::string fs::basename(const string&)’:
filesystem.h:72:28: error: could not convert ‘boost::filesystem3::path::leaf() const()’ from ‘boost::filesystem3::path’ to ‘std::string {aka std::basic_string<char>}’
filesystem.h: In function ‘std::vector<std::basic_string<char> > fs::filelist(const string&, const std::vector<std::basic_string<char> >&, std::string)’:
filesystem.h:129:44: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h:131:50: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h:133:50: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h:135:50: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h:137:50: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
filesystem.h:139:50: error: ‘class boost::filesystem3::path’ has no member named ‘native_file_string’
答案1
最后可以让它工作,只需要替换native_file_string()
为。并将函数string()
内部替换为basename
return fspath.leaf()
return boost::filesystem::basename(path)