由网友(三岁就很拽)分享简介:我在C源代码中包含了库。但我收到编译错误。Error: **undefined reference to 'sqrt'**undefined reference to 'atan'如何链接到CMakeLists.txt中的?推荐答案Cmakelists.txt文件类似:cmak...
我在C源代码中包含了<math.h>
库。但我收到编译错误。
Error:
**undefined reference to 'sqrt'
**undefined reference to 'atan'
如何链接到CMakeLists.txt
中的<math.h>
?
推荐答案
Cmakelists.txt
文件类似:
cmake_minimum_required(VERSION 3.6)
project(project_name)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
set(SOURCE_FILES main.c)
add_executable(project_name ${SOURCE_FILES})
并且您必须为<math.h>
target_link_libraries(project_name PRIVATE m)
仅此而已。
相关推荐
最新文章