cmake: error: symbol(s) not found for architecture x86_64 mac os 使用boost asio

时间:2021-04-12 20:02:10

最近在使用boost的asio库,在mac osx 上编写网络服务程序报错:

:-1: error: symbol(s) not found for architecture x86_64

然后在CMakeList.txt的boost 加filesystem systen依赖:

find_package(Boost COMPONENTS filesystem system  REQUIRED)

然后报了新的错误:

 

dyld: Library not loaded: libboost_filesystem.dylib

Referenced from: /Users/xxx/Desktop/project/build-xxxxx-unknown-Default/xxxxx

Reason: image not found

程序异常结束。

 

没有找到库,我们在cmake里面把静态库打开即可:

set(Boost_USE_STATIC_LIBS ON)