• 6289阅读
  • 10回复

编译qtopia到最后出现错误 [复制链接]

上一主题 下一主题
离线lonelyghost
 
只看楼主 倒序阅读 楼主  发表于: 2006-03-31
我现在试着交叉编译qtopia1.7,到最后却出现错误:
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.2.1/libgcc.a(_udivsi3.oS)(.text+0x0): In function `__udivsi3':
: multiple definition of `__udivsi3'
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.2.1/libgcc.a(_divsi3.oS)(.text+0x0): In function `__divsi3':
: multiple definition of `__divsi3'
/usr/local/arm-linux/bin/../lib/gcc-lib/arm-linux/3.2.1/libgcc.a(_umodsi3.oS)(.text+0x0): In function `__umodsi3':
.
.
.

等等,很多这样的错误.

请问这是怎么回事啊?

郁闷死拉,编译了好几天都没弄好.

班主,高手们,帮帮忙啊
[ 此贴被XChinux在2006-03-31 18:22重新编辑 ]
离线lonelyghost
只看该作者 1楼 发表于: 2006-04-01
高手们到那里去啦?
说点建议嘛
离线lonelyghost
只看该作者 2楼 发表于: 2006-04-01
怎么都是只看不说话啊.
帮我顶一下啊
离线lonelyghost
只看该作者 3楼 发表于: 2006-04-08
哎……哎……哎……
哎……哎……哎……
哎……哎……哎……
离线linuzer

只看该作者 4楼 发表于: 2006-04-08
好奇怪的错误
你是不是环境变量设置的有问题啊
离线hunhunzi

只看该作者 5楼 发表于: 2006-04-08
我以前也出现过这种情况,但忘了怎么解决了,

遇到这种情况一定要仔细检查环境变量和各个链接库的路径。
华曼科技网
www.whaman.com
->BBS
技术论坛提供各种嵌入式系统学习资料下载!
欢迎您到来!
离线angusliu

只看该作者 6楼 发表于: 2006-04-08
转贴:

链接时库文件的顺序
将多个.o文件链接成可执行文件的时候。如果链接的顺序不对,会产生错误。
《An introduction of gcc》里面有下面一段话:
On Unix-like systems, the traditional behavior of compilers and linkers
is to search for external functions from left to right in the object files
specified on the command line. This means that the object file which
contains the definition of a function should appear after any files which
call that function.

但是也说了:
Most current compilers and linkers will search all object files, regardless
of order, but since not all compilers do this it is best to follow the
convention of ordering object files from left to right.

链接库的时候,也存在这个问题。
今天写程序做了一下试验,发现gcc和我现在用的一个板子的编译器都可以不用严格按照顺序。
但是同时发现了另一个问题,就是我们自己的操作系统提供的库文件有两个:libgcc.a和libcs.a。
链接的时候要加上 -lcs -lgcc ,如果这两个顺序搞乱了,就会报错。

xscale-elf-ld -L../../lib -o main test1.o test2.o main.o \
-lgcc \
-lcs
xscale-elf-ld: warning: cannot find entry symbol _start; defaulting to 00008000
../../lib/libcs.a(_uprint.o): In function `outnum':
_uprint.o(.text+0x1ac): undefined reference to `__modsi3'
_uprint.o(.text+0x1c8): undefined reference to `__divsi3'
../../lib/libcs.a(_uprint.o): In function `outnum_u':
_uprint.o(.text+0x2e0): undefined reference to `__umodsi3'
_uprint.o(.text+0x2f4): undefined reference to `__udivsi3'
../../lib/libcs.a(fvwrite.o): In function `__sfvwrite':
fvwrite.o(.text+0x270): undefined reference to `__udivsi3'
make.exe: *** [main] Error 1

为什么编译器在搜索目标文件的时候可以不看顺序,搜索库文件的时候却会报错呢?


下面是hh的解答:
不依命令行的顺序的话就得重复扫描目标文件,我猜可能是重复扫描库文件的开销比较大所以必须在命令行指定正确的顺序。海东有空也可读读此书:
http://www.iecc.com/linker/
离线angusliu

只看该作者 7楼 发表于: 2006-04-08
你也可以试试2.95.3版的编译器
离线lonelyghost
只看该作者 8楼 发表于: 2006-04-10
谢谢angusliu 兄台的回答.
我再试试!
[ 此贴被lonelyghost在2006-04-10 12:15重新编辑 ]
离线lonelyghost
只看该作者 9楼 发表于: 2006-04-11
我昨天换了交叉编译器,居然就顺利地编译通过啦!
看来还真是编译器的问题!
离线lonelyghost
只看该作者 10楼 发表于: 2006-04-12
人气很旺啊!!
快速回复
限100 字节
 
上一个 下一个