gcc 引用math.h头文件,编译出现undefined reference to `pow‘等错误时,需要加参数-lm.
2013-03-21 11:22
453 查看
在自己编写的函数中调用数学函数时,如下例子:
出现编译问题:
解决方法:
问题:
为什么在函数中调用math.h头文件需要加 -lm参数,而在main中调用却不需要?
#include<stdio.h> #include<math.h> void p(void) { printf("%g\n", pow(2, 3)); } int main() { p(); return 0; }
出现编译问题:
undefined reference to `pow'
解决方法:
gcc pow.c -lm
问题:
为什么在函数中调用math.h头文件需要加 -lm参数,而在main中调用却不需要?
相关文章推荐
- gcc 引用math.h头文件,编译出现undefined reference to `pow‘等错
- gcc 编译出现undefined reference to‘pthread_create’的错误
- GCC编译uboot出现(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'错误的解决的方法
- GCC编译uboot出现(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'错误的解决办法
- Libcurl使用OpenSSL编译出现undefined reference to `COMP_CTX_free'错误备忘
- gcc编译出现undefined reference to 'pthread_create'的解决方法
- linux编译出现undefined reference to symbol 'pthread_create错误解决方案
- undefined reference to `__gnu_mcount_nc'的解决 在编译内核时出现了如下错误:
- cocos2d-x 使用ndk编译 x86 出现 in function Curl_resolv_timeout: undefined reference to 'sigsetjmp' 错误
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- 编译出现这种错误 undefined reference to '__gxx_personality_v0'
- Eclipse - Eclipse gcc-none-arm 编译出现undefined reference to `_sbrk'
- 编译出现"undefined reference to `GTK_WIDGET_REALIZED',`GTK_WIDGET_VISIBLE' "相关错误的解决方法
- 关于GCC模板出现"undefined reference to"的错误
- PHP 编译安装时出现 undefined reference to `libiconv' 错误的解决方法
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- 编译3.10内核 出现错误 “undefined reference to...." 解决方法
- 用gcc-none-arm 编译出现undefined reference to `_sbrk'
- 编译node-v4.2.1,出现错误:undefined reference to getpwuid_r
- TORNADO下编译出现undefined reference to `itoa'错误