Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532782
  • 博文数量: 150
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-17 00:19
文章分类

全部博文(150)

文章存档

2011年(1)

2009年(14)

2008年(135)

我的朋友

分类: LINUX

2008-04-19 10:14:48

是交叉工具链hybus-arm-linux-R1.1


tmake 生成 makefile文件

然后 make 时出出了问题


 arm-linux-g++  -o hello    -L/pxa255/qt-2.3.7//lib -lm -lqte
/usr/local/hybus-arm-linux-R1.1/arm-linux/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [hello] Error 1

然后判断是hybus-arm-linux-R1.1没有libstdc++库,然后copy了我自己交叉编译的库中的libstdc++.a:

[root@localhost 2.95.3]# cp libstdc++.a /usr/local/hybus-arm-linux-R1.1/lib

又出问题:
 /usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o: In function `_start':
/usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1



再copy一下,到hybus-arm-linux-R1.1/lib/gcc-lib/arm-linux/2.95.3/
下还是这个错
 /usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o: In function `_start':
/usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1


查看libstdc++
 file libstdc++.a

libstdc++.a: symbolic link to ../../../../arm-linux/lib/libstdc++.a.2.10.0

原来是个符号连接:

再找到实体,复制看样子怎么样?
还是报错:
[root@localhost lib]# cp libstdc++.a* /usr/local/hybus-arm-linux-R1.1/lib
cp: error while loading shared libraries: libc.so.6: ELF file OS ABI invalid
========================================================

ilename: testc.cpp

代碼:


#include

using namespace std;

int main()
{ cout << "Hello C++ " << endl;
    return 0;
}


[root@localhost md5]# g++ -o testc testc.cpp
↑ g++編譯成功 可以執行!!

[root@localhost md5]# arm-linux-g++ -o testc testc.cpp
testc.cpp:1: iostream: ?????????
↑ arm-linux-g++編譯失敗!!

我在终端中采用了自己编译的tool-chain中的arm-linux-g++倒是通过了
又回过去用我的arm-linux-g++编译还是这个错误:


 /usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o: In function `_start':
/usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1



看一个文章说是因为内核版本问题吧,交叉工具链不同,在生成glibc库时要用kenel的version.h,那么我的工具链库中的version.h和hybus-arm-linux-R1.1工具链中内核的可能不一样。
看到一文章说

.



./configure -xplatform linux-arm-g++

make
注:这里需要libstdc++.so和libgcc_s.so库,hybus-arm-linux-R1.1/lib没有,所以要从网上下载;版本一定要是2.95.3。



还没弄过库,试一下,关键是配置./configure参数怎么写!!这个我不太懂

=================================================================
一下午也弄了,没弄过,就用我成功的交叉编译环境中
 /home/qing/arm_toolchain/tools/lib/gcc-lib/arm-linux/2.95.3/
文件夹也考过去了,这样用hybus的arm-linux-g++能编译.cpp文件但还是过不了我的那写得附件上的那个程序还是报错:

/usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o: In function `_start':
/usr/local/hybus-arm-linux-R1.1/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1
===================================
用qt/e自带的例子中的hello.pro 修改,反而能编译通过

这是我写得hello.pro:


SOURECE =hello.cpp
CONFIG += qt warn_on release


这是修改例子后的


CONFIG += qt warn_on release
HEADERS =
SOURCES = hello.cpp \

TARGET = hello

REQUIRES=


修改我的SOURECE为SOURCE,看能不能过:
还是出错
===========================

/home/qing/arm_toolchain/tools/arm-linux/lib/crt1.o: In function `_start':
/home/qing/arm_toolchain/tools/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1

================================================


再加入HEADERS项
看结果:---tmake hello.pro -o  makefile
       -- make
还出错:
===========================

/home/qing/arm_toolchain/tools/arm-linux/lib/crt1.o: In function `_start':
/home/qing/arm_toolchain/tools/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1

================================================
再改SOURCE为SOURCES看结果:
=============================
[root@localhost hello_example]# tmake hello.pro -o makefile
[root@localhost hello_example]# make
arm-linux-g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/pxa255/qt-2.3.7//include -o hello.o hello.cpp
arm-linux-g++  -o hello hello.o   -L/pxa255/qt-2.3.7//lib -lm -lqte

====================================
没报错,现在19:01分,马上就要12个小时,为了这么这错误,竞花费了12个小时。天啊,我找stdlibc++库,发现是个stdlib.a还是个链接文件,又copy了交叉编译好的的gcc-2.95.3文件夹到hybus的文件夹。

竞然是这个错误。应该有SOURCES,我再把HEADERSGG 一项去掉看结果。
还是出错了!:
=================================
/home/qing/arm_toolchain/tools/arm-linux/lib/crt1.o: In function `_start':
/home/qing/arm_toolchain/tools/arm-linux/lib/crt1.o(.text+0x2c): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [hello] Error 1

========================================
看来问题在hello.pro 文件上。

这就是一天的收获!!!!!!!啊,我用了什么思维方式,一开始出现是hybus连arm-linux-g++需要libstdc++库,而这它没有,连一个hello.cpp文件也编不了,上网找没找到方法,编译库也不会,就copy了我交叉工个链里的那个有libstdc++的文件夹。最后发现qt-2.3.7文件夹下的例子可以编译通过,而我写得编译不过,最后才想到我写得格式有问题。。

这事办得,马上就是12个小时,共产主义实现技术诞生也一周年了。但没人相信,我也不想专注这个无人无津的技术了,还是专心于嵌入式开发吧,同样是创造。虽然痛苦,但能有收获也不错了。搞共产主义有什么?除了自己孤芳自赏。


===========正确的格式============
CONFIG += qt warn_on release
HEADERS =
SOURCES = hello.cpp \

TARGET = hello

REQUIRES=
=================================

阅读(2638) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~