我想用Meson构建一个新的c项目.我需要的第一件事是
Boost库的依赖项.但是虽然Boost库安装在我的Arch系统上(标题
和libs),Meson抱怨它找不到它们.
这是介子构建文件:
project('myproj', 'cpp')
boost_dep = dependency('boost')
executable('myproj', 'main.cpp', dependencies : boost_dep)
main.cpp源文件:
int main()
{
return 0;
}
部分列出了我系统上安装的一些Boost文件:
$ls /usr/lib/libboost*|head -n5; ls /usr/include/boost/*|head -n5
/usr/lib/libboost_atomic.a
/usr/lib/libboost_atomic.so
/usr/lib/libboost_atomic.so.1.65.1
/usr/lib/libboost_chrono.a
/usr/lib/libboost_chrono.so
/usr/include/boost/aligned_storage.hpp
/usr/include/boost/align.hpp
/usr/include/boost/any.hpp
/usr/include/boost/array.hpp
/usr/include/boost/asio.hpp
我项目中的ninja命令输出:
[0/1] Regenerating build files.
The Meson build system
Version: 0.43.0
Source dir: /home/io/prog/myproj/src
Build dir: /home/io/prog/myproj/builddir
Build type: native build
Project name: myproj
Native C++ compiler: c++ (gcc 7.2.0)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Dependency Boost () found: NO
Meson encountered an error in file meson.build, line 2, column 0:
Dependency "boost" not found
[...]
我错过了什么?
解决方法:
以下问题解决了我的问题:
Boost not detected on Fedora · Issue #2547
我用以下内容替换了介子构建文件:
project('myproj', 'cpp')
cxx = meson.get_compiler('cpp')
boost_dep = [
cxx.find_library('boost_system'),
cxx.find_library('boost_filesystem'),
]
executable('myproj', 'main.cpp', dependencies : boost_dep)