linux编译出现undefined reference to `pow‘的错误
来源:互联网 发布:七分网络查分 编辑:程序博客网 时间:2024/05/16 06:24
我的一个h264+aac封装成avi的应用,用到了pow函数,也加了<math.h>头文件了,在linux环境下编译,然后我提示:undefined reference to `pow'
然后我就测试了一下,发现,如果pow(a,b),如果a,b都是常量时,是不会出现提示的,但是,如果a,b中有任何一个是变量,那么编译时都会出现提示。
原因:
因为math.h不是C运行库函数,就像linux下线程函数库pthread.h也不是,都需要在编译时连接该库
如果你有IDE(如eclipse)+ GCC 开发C程序,可以在项目属性中编译命令中添加-lm,作用是一样的
C标准主要由两部分组成,一部分描述C的语法,另一部分描述C标准库。C标准库定义了一组标准头文件,每个头文件中包含一些相关的函数、变量、类型 声明和宏定义。要在一个平台上支持C语言,不仅要实现C编译器,还要实现C标准库,这样的实现才算符合C标准。不符合C标准的实现也是存在的,例如很多单 片机的C语言开发工具中只有C编译器而没有完整的C标准库。
在Linux平台上最广泛使用的C函数库是glibc,其中包括C标准库的实现。几乎所有C程序都要调用glibc的库函数,所以glibc是Linux平台C程序运行的基础。glibc提供一组头文件和一组库文件,最基本、最常用的C标准库函数和系统函数在libc.so库文件中,几乎所有C程序的运行都依赖于libc.so,有些做数学计算的C程序依赖于libm.so,以后我们还会看到多线程的C程序依赖于libpthread.so。以后我说libc时专指libc.so这个库文件,而说glibc时指的是glibc提供的所有库文件。
glibc并不是Linux平台唯一的基础C函数库,也有人在开发别的C函数库,比如适用于嵌入式系统的uClibc。
#include <math.h>
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
0 0
- linux编译出现undefined reference to `pow‘的错误
- linux编译出现undefined reference to symbol 'pthread_create错误解决方案
- NDK编译出现undefined reference to错误
- 交叉编译中出现的 'Undefined reference to __aeabi_read_tp' 错误
- 编译什么时候出现Undefined reference to 的错误
- gcc 编译出现undefined reference to‘pthread_create’的错误
- undefined reference to `pow'
- undefined reference to `pow'
- 编译tslib1.4出现错误undefined reference to rpl_malloc错误
- TORNADO下编译出现undefined reference to `itoa'错误
- 编译出现这种错误 undefined reference to '__gxx_personality_v0'
- 编译WU FTPD出现"undefined reference to crypt"错误解决方法
- 编译3.10内核 出现错误 “undefined reference to...." 解决方法
- 编译node-v4.2.1,出现错误:undefined reference to getpwuid_r
- QT编译出现错误 “undefined reference to ‘vtable for xxx’”
- NDK编译出现 error: undefined reference to 错误
- 在liunx编译C语言程序出现Undefined reference to pthread_create in Linux 错误*
- 编译mtk的android工程,会出现如图所示的错误: undefined reference to “
- script标签关闭的写法
- [Leetcode] Letter Combinations of a Phone Number (Java)
- tdb---数据库
- SuperSpider——打造功能强大的爬虫利器
- 基于BOLT的仿迅雷加速器界面开发(一)
- linux编译出现undefined reference to `pow‘的错误
- 插入排序思想及其实现
- Android源代码仓库及其管理工具Repo分析
- ZOJ 3229 Shoot the Bullet 有源汇最大流(好题)
- 计算机操作系统——进程管理(1)
- 贪心算法思想及实现
- 索爱X10i小技巧,X10i的三种模式(新手扫盲)
- 短视频的那些事
- 被大家忽略的从代码到可执行文件中间的过程