ubuntu 中How to fix undefined reference to `sqrt' in Eclipse

Friday, September 23, 2011

How to fix undefined reference to `sqrt' in Eclipse

- Re: How to use math.h in Eclipse with gcc? [message #214058 is a reply to message #213974] Wed, 16 April 2008 04:50 Go to previous messageGo to next message
Tracy Miranda is currently offline Tracy Miranda
Messages: 15
Registered: July 2009
Junior Member
 
Hi Warren,

The "-lm" option is a linker option - looks like you've added it to the 
Compiler 'Other flags', where it has no effect.
Add it to the linker options, Libraries-> add it in as a new library "m", 
this will automatically add on the -l to the option.
(Alternately, you can add "-lm" to the Miscellaneous->Linker Flags box, but 
I highly recommend the previous option).

Tracy

"Warren Tang" <warren.c.tang@gmail.com> wrote in message 
news:fu2ftr$bai$1@build.eclipse.org...
>
> I tried to add the "-lm" option for gcc in the project properties:
> -c -fmessage-length=0 -std=c99 -lm
>
> However the eclipse still complains that:
> undefined reference to `sqrt'
>

Math.h problem 
Programming in C using Eclipse in Linux is great, however when i added variables that were doubles into the "sqrt" function from the "math.h" library there was a problem that came up.
undefined reference to `sqrt'
After a little bit of research, in Eclipse, go to Project > Properties > C/C++ Build > Settings > GCC C Linker > Miscellaneous > add "-lm" to the "Linker Flags" text field. That way it is properly linked to the project.
http://cboard.cprogramming.com/c-programming/88943-undefined-reference-sqrt.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值