如何使用CMake链接<Math.h>库?如何使用、链接、CMake、amp

由网友(三岁就很拽)分享简介:我在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>

推荐答案

谷歌将解决苹果 iOS 15 上搜索结果禁用 AMP 问题,修复一些bug

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)

仅此而已。

阅读全文

相关推荐

最新文章