使用CMake添加数学库 [英] Adding math library with CMake
本文介绍了使用CMake添加数学库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将math标志或库添加到我的CMake文件?此帖子引用添加了目标链接库,但我不太熟悉C.。其他帖子 - 有人可以演示一个例子。 文档我正在使用C,我收到一个<$ c $
How do I add the math flag or library to my CMake file? This post references adding a target link library, yet I am not too familiar with C. An Additional post - Could someone please demonstrate an example. Documentation I am using C and I receive an undefined reference to 'pow'
with the pow method of the math header.
cmake_minimum_required(VERSION 3.3)
project(CSCI-E-28-Unix-Linux-Systems-Programming)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
CMakeLists.txt
getchar.c
main.cpp
hw0
more01.c)
#target_link_libraries(<math.h> m)
add_executable(main main.cpp)
add_executable(getchar getchar.c)
add_executable(more01 more01.c)
add_executable(argu print_all_arguments.c)
add_executable(chars chars.c)
add_executable(ch4 ch4.c)
推荐答案
您必须使用 target_link_libraries(ch4 m)
。
第一个参数必须是目标。因此必须在 add_executable(ch4 ch4.c)
后使用。
这篇关于使用CMake添加数学库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文