2011.04.07 By Pafone
先来说下最后的成功情况,再来说过程中的各种蛋痛。
条件:1.环境 RedHat Linux 9.0 arm-linux-gcc 2.95.3
2.已经编译好的libX11.so 和 libXext.so
补充:gcc的版本[root@pafone vmshare]# arm-linux-gcc -v
Reading specs from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/specs
gcc version 2.95.3 20010315 (release)
编译:
1.解压 tar vxzf fltk-1.1.10-source.tar.gz
2.进入fltk-1.1.10, 接着 ./configure --host=arm-linux
3. make 之后便会在 lib那里生成
libfltk.a libfltk_images.a libfltk_png.a README.lib
libfltk_forms.a libfltk_jpeg.a libfltk_z.a
注:这个过程中最后是有错误的,是在生成fluid那里,它要用到 -lX11与-lXext库,因为我没有提供给它。不过这个不影响,因为目前我用不到fluid
附:生成错误处
Linking fluid...
/usr/X11R6/lib/libXext.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[1]: *** [fluid] 错误 1
make: *** [all] 错误 1
成功得到所要文件:利用FL文件夹里的头文件与lib文件夹里的库文件便可以编译自己的程序了。
探索中的各种蛋痛:
1.利用arm-linux-gcc 3.4.1编译生成库
[root@pafone bin]# ./arm-linux-gcc -v
Reading specs from /usr/local/arm/3.4.1/bin/../lib/gcc/arm-linux/3.4.1/specs
Configured with: /opt/crosstool/crosstool-0.28/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2 --with-float=soft --with-headers=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2/arm-linux/include --with-local-prefix=/opt/crosstool/arm-linux/gcc-3.4.1-glibc-2.3.2/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.1
将生成的libfltk.a和libX11.so和libXext.so链接应用程序时,报错。
hardware FP与software FP不能互链。
查库的信息:
[root@pafone fltktest]# arm-linux-readelf -h libs/libX11.so
ELF Header:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM
Version: 0x1
Entry point address: 0xf458
Start of program headers: 52 (bytes into file)
Start of section headers: 695912 (bytes into file)
Flags: 0x2, has entry point
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 25
Section header string table index: 22
用同样命令查得libfltk.a在Flags处是software FP,冲突了。网上查得知可在gcc的flags处加入 –mhard-float (相对应是-msoft-float)来解决。
于是./configure --host=arm-linux CXXFLAGS=-mhard-float
得到的libfltk.a中用arm-linux-readelf查,竟有部分o文件是hardware FP,部分是software FP,当然的链接应用程序时便不通过了。查看configure后生成的Makefile发现它用了arm-linux-g++与arm-linux-gcc 其中arm-linux-gcc对应的是CFLAGS,那好来./configure --host=arm-linux CXXFLAGS=-mhard-float CFLAGS=-mhard-float 但configure通不过,说C Compiler生成不了可执行文件。蛋痛中,不知怎么解决。。。
2.利用arm-linux-gcc 4.3.2编译生成库
[root@pafone bin]# ./arm-linux-gcc -v
./arm-linux-gcc: line 3: exec: arm-none-linux-gnueabi-gcc: not found
[root@pafone bin]# ./arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/lite-respin/linux/src/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2008q3-72' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)
这个没说明是soft-float,应该不用加-mhard-float了,也生成了libfltk.a,文件比上面的两个gcc版本生成的都要大。但链接时说libX11.so与libXext.so那里找不到glibc2xxx的一些函数,不是很记得什么函数了,可能版本太新了,库中没了原先的libX11.so等用过的库函数,继续蛋痛。。。
最后没办法,只能找回2.95.3的那编译器。
总结:
1.hardware FP与 software FP不能互链。
2.链接库时最好用跟库同一版本的编译器
另外:关于ARM Float Point的一篇文章 http://hi.baidu.com/romashell/blog/item/56c23ceef45523252df53489.html 能帮助很好理解这个FP的来源