GCC 中 undefined reference to ‘ceil’ collect2:ld returned 1 exit status 错误
来源:互联网 发布:印度军工 知乎 编辑:程序博客网 时间:2024/06/05 11:58
当我们用gcc编译一个c文件时,如果用到了math.h中的一些数学函数,例如:ceil(),floor()等,可能会出现如下错误:
undefined reference to ‘ceil’
collect2:ld returned 1 exit status
主要是因为使用math.h中声明的库函数时,gcc命令行必须加-lm选项,如果没有加就会出现上面的错误,原因在于数学函数位于libm.so库文件中,-lm选项告诉编译器,我们程序中用到的数学函数要到这个库文件里找。我们平时用到的大部分函数(例如printf)位于libc.so库文件中,使用libc.so中的库函数在编译时不需要加-lc选项,是因为这个选项是gcc默认的选项。所以在使用gcc命令去执行c文件时,如果使用了math.h中的库函数的时候,一定要加-lm选项。《摘自Linux c编程一站式学习》
例如:
阅读全文
0 1
- GCC 中 undefined reference to ‘ceil’ collect2:ld returned 1 exit status 错误
- GCC 中 undefined reference to ‘ceil’ collect2:ld returned 1 exit status 错误
- undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status
- undefined reference to `libiconv_open' collect2: ld returned 1 exit status
- undefined reference to `pthread_create' collect2: ld returned 1 exit status
- Linux gcc编译提示:undefined reference to `sqrtf' collect2: error: ld returned 1 exit status
- 【错误笔记】undefined reference to `sqrt' collect2: ld returned 1 exit status
- 编译器错误:/tmp/ccyOgqYQ.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status
- pthread线程创建出现undefined reference to `pthread_create' collect2: error: ld returned 1 exit status
- undefined reference to `typeinfo for IA' collect2: ld returned 1 exit status
- undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit stat
- collect2: ld returned 1 exit status错误.
- collect2: ld returned 1 exit status错误.
- cocos2dx向android平台移植出现问题undefined reference to 'sqlite3_close' collect2: ld returned 1 exit status
- Linux gcc编译error:"collect2: ld returned 1 exit status"
- QT编译错误:collect2: ld returned 1 exit status
- Android 编译错误:collect2: ld returned 1 exit status
- QT中的error: collect2: ld returned 1 exit status错误
- HBase性能调优<转>
- 【工具】文档编辑器
- 基础练习 回文数
- Redis 集成Spring(spring-data-redis)
- MySQL 数据库性能优化之索引优化
- GCC 中 undefined reference to ‘ceil’ collect2:ld returned 1 exit status 错误
- Matlab 跨空间变量传递和赋值
- MySQL中tinytext、text、mediumtext和longtext详解
- F
- KNN(K-NearestNeighbor)算法
- http请求方法与状态码
- more effective c++条款总结
- python基础八_面向对象编程
- 大数据架构的未来