Ubuntu Uundefined reference to symbol 'pow@@GLIBC_2.2.5'

今天建了一个工程,make后,报错 /usr/bin/ld: Caculator/Calculator.o: undefined reference to symbol 'pow@@GLIBC_2.2.5'

因为使用了mathematical functions,一开始我是在makefile里添加了-lm,但是仍报错,后来检查发现我用的是gcc,于是我把$(CC)改成g++后不报错了。我的工程本来是在Qt里面建的,今天改成自己写makefile管理,报了这个错,Qt工程创建的makefile是个很好的学习范例,我有些东西是看了Qt创建的makefile然后学来的,真的很好用。

  改完后我看了下cc是啥,确实是gcc

@:~/Documents/InterviewSolution/InterviewSolution$ which cc
/usr/bin/cc
@:~/Documents/InterviewSolution/InterviewSolution$ ls -al /usr/bin/cc
lrwxrwxrwx 1 root root 20 11月  8 19:59 /usr/bin/cc -> /etc/alternatives/cc
@:~/Documents/InterviewSolution/InterviewSolution$ ls -al /etc/alternatives/cc
lrwxrwxrwx 1 root root 12 11月  8 19:59 /etc/alternatives/cc -> /usr/bin/gcc

参考

If your code includes mathematical functions (like exp, cos, etc.), you need to link to the mathematics library libm.so. This is done, just like for serial compiling, by adding -lm to the end of your compile command, that is,

mpicc -o sample sample.c -lm

If you are working with C++ you should not compile using the C compiler, use g++ instead.

https://stackoverflow.com/questions/30013845/compiling-lib-x86-64-linux-gnu-libm-so-6-error-adding-symbols-dso-missing

有人在动态链接库显示调用时使用到的dlclose函数:undefined reference to symbol 'dlclose@@GLIBC_2.2.5' 在QT工程的.pro文件中添加 LIBS=-ldl。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值