c - 即使使用“-lm”标志也出现“未定义的对‘floorf’的引用”错误
问题描述
在我的代码中使用 math.h 库中的 floorf 函数会导致“未定义对‘floorf’的引用”错误。我已经编辑了我的 tasks.json 以包含“-lm”标志文件,如下所示:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc-9 build active file",
"command": "/usr/bin/gcc-9",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lm"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Generated task by Debugger"
}
],
"version": "2.0.0"
}
但是,没有任何改变,我仍然收到错误消息。
我在 Vscode 中使用 WSL。
编辑:这是错误输出:
Build finished with error:
/usr/bin/ld: /tmp/ccg38t0m.o: in function `fill1d':
/home/viktor/upr/cosSim.c:51: undefined reference to `floorf'
collect2: error: ld returned 1 exit status
The terminal process failed to launch (exit code: -1).
enter code here
解决方案
推荐阅读
- javascript - Next.js SSR/ISR 为非静态页面创建 HTML 静态文件
- c# - 为什么这个字符串不知从哪里出现
- amazon-web-services - 无法将 Amazon SQS 附加到 Amazon S3 事件通知
- python - 如何从点分隔字符串中的单词中挑选出第一个字母
- python - 如何将索引、列表值插入字典值(基于另一个列表的长度)?
- java - 删除对象时是否使用诸如 isDestroyed 之类的布尔值最佳实践?
- html - #id:hover { background: no-repeat url(...);} 不起作用?
- typescript - 如何将动态参数名称设置为类型定义
- amazon-web-services - 为什么我的 S3 存储桶策略拒绝跨账户访问?
- javascript - 通过 java 脚本更改货币 Shopify