未定义对函数的引用 [英] undefined refrence to a function
问题描述
我一直在尝试编译一些原本应该工作的源代码,并且会出现一些编译错误。错误与
sqrt(),log()和round()函数有关。我有math.h包含并制作
确定它在路径中。我已经在论坛上看到,有些人已经通过告诉GCC链接数学库来解决这个问题,如果它没有通过
默认完成。
所以,使用gcc -lm帮助解决了定义
前两个函数的问题。但是,round()仍未定义:undefined
引用round()
我发现的另一个建议是检查是否编译器
正在使用C99 VS C90库。在使用GCC 4.0.2时,我遇到了这些问题,这是非常困难的。
您对此有何看法?为什么这是个问题?至于我理解为
,在C99中定义了round(),gcc 4.0.2应该有C99库附带的
。
谢谢
Hi,
I have been trying to compile some source code that is supposed to be
working and getting some compilation errors. The errors are with
sqrt(), log() and round() functions. I have math.h included and made
sure it''s in the path. I have read on the forums that some have fixed
the problem by telling GCC to link math libraries if it''s not done by
default.
So, using gcc -lm helped to resolve the problems with defining the
first two functions. However, round() is still undefined: "undefined
reference to round()"
Another suggestion that I have found is to check whether the compiler
is using C99 VS C90 library. This is quite stange that I have faced
these problems while using GCC 4.0.2.
What do you think about this? Why is this a problem? As far as I
understood, round() has been defined in C99 and gcc 4.0.2 should have
come with C99 libraries.
Thank you
推荐答案
bobrics写道:
bobrics wrote:
sqrt(),log()和round()函数有关。我有math.h包含并确保它在路上。我已经在论坛上看到有人已经通过告诉GCC链接数学库来解决这个问题,如果它不是默认的那样。
那么,使用gcc - lm帮助解决了定义前两个函数的问题。但是,round()仍未定义:undefined
对round()的引用
我发现的另一个建议是检查编译器是否正在使用C99 VS C90库。我在使用GCC 4.0.2时遇到了这些问题,这是非常困难的。
你怎么看待这个?为什么这是个问题?据我所知,round()已在C99中定义,gcc 4.0.2应该有C99库。
Hi,
I have been trying to compile some source code that is supposed to be
working and getting some compilation errors. The errors are with
sqrt(), log() and round() functions. I have math.h included and made
sure it''s in the path. I have read on the forums that some have fixed
the problem by telling GCC to link math libraries if it''s not done by
default.
So, using gcc -lm helped to resolve the problems with defining the
first two functions. However, round() is still undefined: "undefined
reference to round()"
Another suggestion that I have found is to check whether the compiler
is using C99 VS C90 library. This is quite stange that I have faced
these problems while using GCC 4.0.2.
What do you think about this? Why is this a problem? As far as I
understood, round() has been defined in C99 and gcc 4.0.2 should have
come with C99 libraries.
尝试gcc列表圆形应该在那里。
-
Ian Collins。
Try a gcc list, round should be there.
--
Ian Collins.
Ian Collins写道:
Ian Collins wrote:
bobrics写道:
bobrics wrote:
我一直在尝试编译一些应该是
工作并获得一些编译错误。错误与
sqrt(),log()和round()函数有关。我有math.h包含并确保它在路上。我已经在论坛上看到有人已经通过告诉GCC链接数学库来解决这个问题,如果它不是默认的那样。
那么,使用gcc - lm帮助解决了定义前两个函数的问题。但是,round()仍未定义:undefined
对round()的引用
我发现的另一个建议是检查编译器是否正在使用C99 VS C90库。我在使用GCC 4.0.2时遇到了这些问题,这是非常困难的。
你怎么看待这个?为什么这是个问题?据我所知,round()已在C99中定义,gcc 4.0.2应该有C99库。
Hi,
I have been trying to compile some source code that is supposed to be
working and getting some compilation errors. The errors are with
sqrt(), log() and round() functions. I have math.h included and made
sure it''s in the path. I have read on the forums that some have fixed
the problem by telling GCC to link math libraries if it''s not done by
default.
So, using gcc -lm helped to resolve the problems with defining the
first two functions. However, round() is still undefined: "undefined
reference to round()"
Another suggestion that I have found is to check whether the compiler
is using C99 VS C90 library. This is quite stange that I have faced
these problems while using GCC 4.0.2.
What do you think about this? Why is this a problem? As far as I
understood, round() has been defined in C99 and gcc 4.0.2 should have
come with C99 libraries.
尝试gcc列表圆形应该在那里。
Try a gcc list, round should be there.
或者你的平台列表,我在Solaris上没有gcc这个问题。
-
Ian Collins。
Or a list for your platform, I don''t have this problem with gcc on Solaris.
--
Ian Collins.
gcc列表是什么意思?
方式,我尝试使用命令提示符编译文件
而不是像以前那样做Eclipse构建,我刚刚得到
后面的错误。否则它有效。我认为-lm实际上已经修复了问题:
What do you mean by gcc list?
By the way, I have tried compiling the file using just command prompt
and not Eclipse build as I was doing before and I''ve just got the
following errors. Otherwise it works. I think -lm actually has fixed
the problem:
这篇关于未定义对函数的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!