c++ - CMake Error: fatal error : boost/asio.hpp not found without using find_package() for boost
问题描述
Like the heading says I don't wanna use the find_package(Boost) to locate Boost and then the Asio component in it rather I want to do by creating a target library, and then link the target to my executable like this
cmake_minimum_required(VERSION 3.0)
project(final_exe_proj VERSION 1.0)
add_executable(final_exe main.cpp)
find_package(Threads REQUIRED)
add_library(boost_asio INTERFACE)
target_include_directories(boost_asio INTERFACE /usr/local/include/boost/asio.hpp)
target_link_libraries(boost_asio INTERFACE Threads::Threads)
target_link_libraries(final_exe PRIVATE boost_asio)
I have tried doing #include <asio.hpp> but still no luck. What is the right way to do it? Really would appreciate any help. Thanks!
Happy New Year!
解决方案
谢谢艾伦!问题出在target_include_directories行中
关于改变它
target_include_directories(boost_asio INTERFACE /usr/local/include)
在某种程度上,这增加了这个项目的路径,所以现在编译器将能够找到#include <boost/asio.hpp>
推荐阅读
- docker - 使用用户定义的桥接网络在 docker 主机和容器中进行网络设置,其中从主机到容器的 ping 失败
- flutter - 启动 tel: 和电子邮件时出现颤振问题
- react-native - Drawer.Navigator 在里面添加图片,React Native
- algorithm - 最短剩余时间作业优先调度算法说明
- python-3.x - Python中的频谱图
- pandas - 子 DataFrame 保持与原始数据帧的链接
- kotlin - Kotlin 调用就地合约有哪些好处?
- javascript - 如何使用 Map 检查嵌套对象数组中是否存在键
- javascript - 在 for 循环中将数组作为函数的参数传递
- r - 组内的ggplot scale_fill_manual