在Ubuntu 11.10 C数学连接器问题 [英] c math linker problems on Ubuntu 11.10
问题描述
后,我从升级我的Ubuntu出现了一些奇怪的错误(10.11,11.04,我不知道)
11.10。
Some strange error appeared after I upgraded my Ubuntu from (10.11, 11.04 i dont know)
to 11.10.
我收到一个未定义引用'开方',而使用math.h中的和链接
-lm
I am getting an undefined reference to 'sqrt'
while using math.h and linking with -lm
我与的gcc -Wall -g -Werror -Iinclude / -lm的lib / matrix.c的src / analyse.c -o斌/ analyse.o
编译这两个源文件中使用,包括math.h中。
I'm compiling with gcc -Wall -Werror -g -Iinclude/ -lm lib/matrix.c src/analyse.c -o bin/analyse.o
both source-files use and include math.h.
这code编译没有为问题,我并没有太大变化,因为在升级,但现在它不会工作。
This code compiled without problems for and I didn't change much since the upgrade but now it won't work.
你有什么建议,我能做些什么,要找出错误?
Do you have any suggestions what I can do, to find the error?
我很抱歉,如果这个问题被问过;有数学上的链接错误那么多帖子,我没有找到匹配的有一个
I'm sorry, if this question was asked before; there are so many posts on math linker errors and I didn't find a matching one
推荐答案
放置您正在使用的需求库,当你使用它在命令行中使用它的文件之后。所以,放置 -lm
在命令行上的C文件后。
The library that you are using needs to be placed after the files that use it when you are using it from the command line. So place -lm
on after your C files on the command line.
这篇关于在Ubuntu 11.10 C数学连接器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!