简体   繁体   English

GCC错误:未定义参考

[英]GCC error : undefined reference

I am trying to compile some C code on a beagleboard xm. 我正在尝试在beagleboard xm上编译一些C代码。 I try to compile, but I get the error: undefined reference to 'isfinite' which is in the math.h library. 我尝试进行编译,但是出现错误:math.h库中对“ isfinite”的未定义引用。 This code compiles perfectly in all my other computers, and I do include -lm in my makefile. 该代码可以在我的所有其他计算机上完美地编译,并且我的makefile中确实包含-lm。

I suspect that it may be my compiler, maybe it is an over version? 我怀疑这可能是我的编译器,也许是过版本? On the beagleboard it's version 4.3.3, but on my computer it's 4.7.3, but I don't know how to get a later version. 在Beagleboard上,它的版本是4.3.3,但在我的计算机上是4.7.3,但是我不知道如何获得更高的版本。 I thought opkg would automatically get the latest available. 我以为opkg会自动获得最新版本。

Any ideas why this may be happening? 任何想法为什么会发生这种情况?

The function infinite() is part of C99. 函数infinite()是C99的一部分。 Your compiler is by default using an older version of the C language. 默认情况下,您的编译器使用的是C语言的旧版本。 You need to compile with the the flag -std=c99 to enable this macro. 您需要使用标志-std=c99进行编译才能启用此宏。

`gnu89' GNU dialect of ISO C90 (including some C99 features). ISO C90的“ gnu89” GNU方言(包括一些C99功能)。 This is the default for C code. 这是C代码的默认设置。

http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/C-Dialect-Options.html http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/C-Dialect-Options.html

isfinite is part of the C++11 standard and gcc 4.3.3 is to old to know that. isfinite是C ++ 11标准的一部分,而gcc 4.3.3 isfinite知道这一点。 Try int finite(double x); 尝试int finite(double x); or int finitef(float x); int finitef(float x); .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM