问题:collect2: ld returned 1 exit status

syxm 2007-07-25 02:37:49
在程序开始包含了math.h头文件,在函数中调用了POW()指数函数,在编译程序的时候出现了上面那个错误:
/usr/bin/ld: /tem/cckJBf9P.O Undefined pow:in function..
collect2: ld returned 1 exit status
我变换编译方式:gcc -O2 -Wall -o a a.c -lmath 还是不行?
请大虾门指点??
...全文
10670 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
syxm 2007-07-26
  • 打赏
  • 举报
回复
正如dai_weitao(疯狂Linux C++)所说:gcc main.c -o test -lm即可
syxm 2007-07-26
  • 打赏
  • 举报
回复
谢谢,这个问题已经解决了!!
dai_weitao 2007-07-25
  • 打赏
  • 举报
回复
如果用math.h中的函数, 在使用GCC编译时请加入-lm.
gcc main.c -o test -lm
mymtom 2007-07-25
  • 打赏
  • 举报
回复
mymtom@fc6:src/csdn$ cat math.c
#include <math.h>

int main(void)
{
double x, y, z;

x = 3.0;
y = 4.0;
z = pow(x, y);
return 0;
}
mymtom@fc6:src/csdn$ make LDLIBS=-lm math
cc math.c -lm -o math
mymtom@fc6:src/csdn$

cceczjxy 2007-07-25
  • 打赏
  • 举报
回复
-Lmath

或则这样
cceczjxy 2007-07-25
  • 打赏
  • 举报
回复
gcc -o a a.c
直接就可以了.

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧