如何包含我用 Homebrew 安装的库
How to include a library which I installed with Homebrew
我已经用自制软件安装了 boost 库,如果我写:
include_directories(/opt/homebrew/Cellar)
link_directories(/opt/homebrew/Cellar/boost/1.76.0/)
add_executable(Project main.cpp)
target_link_libraries(Project boost)
然后将其包含在我的脚本中:
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
它没有找到它,当我写:
#include <boost/1.76.0/include/boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
确实找到了,但出现以下错误:
/opt/homebrew/Cellar/boost/1.76.0/include/boost/multiprecision/cpp_int.hpp:12:10: fatal error: 'boost/multiprecision/number.hpp' file not found
#include <boost/multiprecision/number.hpp>
The number.hpp file can't include the boost library.
任何人都可以理解并帮助我吗?
要添加一个Boost header-only库,例如multiprecision
用cmake,通常你需要做的就是:
find_package(Boost)
link_libraries(Boost::headers)
如果 Boost 没有正确安装,您仍然可以添加它:
include_directories(/opt/homebrew/include)
或:
include_directories(/opt/homebrew/Celler/boost/1.76.0/include)
我已经用自制软件安装了 boost 库,如果我写:
include_directories(/opt/homebrew/Cellar)
link_directories(/opt/homebrew/Cellar/boost/1.76.0/)
add_executable(Project main.cpp)
target_link_libraries(Project boost)
然后将其包含在我的脚本中:
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
它没有找到它,当我写:
#include <boost/1.76.0/include/boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
确实找到了,但出现以下错误:
/opt/homebrew/Cellar/boost/1.76.0/include/boost/multiprecision/cpp_int.hpp:12:10: fatal error: 'boost/multiprecision/number.hpp' file not found
#include <boost/multiprecision/number.hpp>
The number.hpp file can't include the boost library.
任何人都可以理解并帮助我吗?
要添加一个Boost header-only库,例如multiprecision
用cmake,通常你需要做的就是:
find_package(Boost)
link_libraries(Boost::headers)
如果 Boost 没有正确安装,您仍然可以添加它:
include_directories(/opt/homebrew/include)
或:
include_directories(/opt/homebrew/Celler/boost/1.76.0/include)