How to include C static libraries in CMAKE project on MAC OS X

孤街浪徒 提交于 2019-12-01 14:23:24

Finally resolved.

Thanks to this resource: http://raycast.net/clion-multiple-binaries

This is how my CMAKE file looks like and everything links:

cmake_minimum_required(VERSION 2.8.4)
project(test001)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)

find_library(corefoundation_lib CoreFoundation)
find_library(cfnetwork_lib CFNetwork)

set(frameworks
    ${cfnetwork_lib}
    ${corefoundation_lib})

add_executable(test001 ${SOURCE_FILES})
target_link_libraries(test001 ${frameworks})

I'm not 100% sure if this is what you ment but you link C static libraries by giving -llibrary flag to your compiler where the name of the library file is liblibrary.a. If the library isn't in some default library location (idk what it is for mac) you can specify the path with -L flag.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!