问题描述
- gcc编译出现了undefined reference to `exp'
- 在Ubuntu下编译word.c
gcc -lm -pthread word.c -o word
还是出现了undefined reference to `exp',
后来有gcc -pthread word.c -o word /usr/lib/libm.a则提示没有/usr/lib/libm.a这个文件,有没有有经验的大侠有解决办法?
解决方案
首先确定有libm.so,虽然一般是肯定有的,locate libm.so确认一下。 要不然把-lm放到gcc编译命令的末尾处试试。
解决方案二:
我在centos下是这么用的: gcc -o word -L. -pthread -L/usr/lib/ -lm word.o
-L/usr/lib这种一般是用来指定第三方库的位置的。
时间: 2024-08-04 00:40:32