在 2012-03-07三的 15:23 +0800,Forest Chen写道:
> 你把target指定成toolchains了。
> 你要在qmake.conf里指定toolchains 可考参以下两个连接。
> 
> http://processors.wiki.ti.com/index.php/Building_Qt
> http://webkit.sed.hu/blog/20100427/qtwebkit-cross-compilation-gcc-arm-linux
> 
> On Wed 07 Mar 2012 02:40:02 PM CST, chenchacha wrote:
> > 在 2012-03-07三的 09:43 +0800,hooxin firefoxmmx写道:
> >> 临时的用-L路径 ,全局修改/etc/ld.so.conf 在ldconfig
> >>
> >>
> >> 在 2012年3月7日 上午9:26,吴亚杰<yajie...@hotmail.com>写道:
> >>
> >>>
> >>> 你可以在/etc/ld.so.conf文件中加入你那个库的路径
> >>> 再运行ldconfig。
> >>> 这样在编译时就会去那个库的路径下查找
> >>>
> >>>> Date: Tue, 6 Mar 2012 23:48:22 +0800
> >>>> From: amankw...@gmail.com
> >>>> To: ubuntu-zh@lists.ubuntu.com
> >>>> Subject: Re: [Ubuntu-zh] 请问编译gcc的时候怎么指定库文件目录
> >>>>
> >>>> On Tue, Mar 06, 2012 at 08:39:20PM +0800, chenchacha wrote:
> >>>>> 我是学电子的,平时用 arm-linux-gcc 交叉工具链。最近用 gcc-4.6.3 编译的
> >>>>> arm-none-linux-gnueabi 交叉工具链在编译Qt代码的时候出现了g++找不到库文件
> >>>>> 的问题
> >>>>>
> >>>>> arm-linux-g++ -lts -Wl,-O1
> >>>>> -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.8.0-arm/lib -o movies
> >>>>> main.o movieplayer.o moc_movieplayer.o
> >>>>> -L/usr/local/Trolltech/QtEmbedded-4.8.0-arm/lib -lQtGui
> >>>>> -L/usr/local/trolltech/tslib/lib/
> >>>>> -L/usr/local/Trolltech/QtEmbedded-4.8.0-arm/lib -lQtNetwork -lQtCore
> >>>>> -lpthread
> >>>>>
> >>> /usr/local/arm/4.6.3/lib/gcc/arm-none-linux-gnueabi/4.6.3/../../../../arm-none-linux-gnueabi/bin/ld:
> >>> skipping incompatible /lib/libpthread.so.0 when searching for
> >>> /lib/libpthread.so.0
> >>>>>
> >>> /usr/local/arm/4.6.3/lib/gcc/arm-none-linux-gnueabi/4.6.3/../../../../arm-none-linux-gnueabi/bin/ld:
> >>> cannot find /lib/libpthread.so.0
> >>>>> collect2: ld 返回 1
> >>>>> make: *** [movies] 错误 1
> >>>>>
> >>>>> 可以看到 arm-none-linux-gnueabi-g++ 跑到根目录 /lib 下面找寻找库文件
> >>>>> libpthread.so.0,而libpthread.so.0 和其他库是放在它自己的目录下面的。
> >>>>>
> >>>>> 我的 gcc 配置选项是
> >>>>> ../configure --target=arm-none-linux-gnueabi \
> >>>>> --prefix=/usr/local/arm/4.6.2/ --enable-languages=c,c++ \
> >>>>> --disable-libgomp --with-cpu=arm920t --with-tune=arm9tdmi
> >>>>> --with-float=soft
> >>>>>
> >>>>> 配置选项只指定了安装目录,编辑器支持的语言和目标体系,去掉了编译会出错的
> >>>>> libgomp ,没有指定库文件目录。但是用 gcc 去编译 c 代码的时候是可以正常去
> >>>>> 自己的库搜索,出问题的是 g++ ,也就是在编译 c++ 代码的时候 g++ 会去根目
> >>>>> 录寻找系统库
> >>>>>
> >>>>>
> >>>> -LPATH指定库文件所在路径,-llibname指定库名称,规则是libabc.so或者libabc.a的库用-labc来链接。
> >
> > 交叉工具链似乎没有去用系统的 ld.so.cache ,修改 ld.so.conf 并 ldconfig
> > 照样编译出错
> >
> > Qt 的 Makefile 自带 -LPATH ,所以加 -LPATH 不管用
> >
> > 这个工具链貌似在编译的时候就出错了,编译 gcc 本身的时候难道还有哪个参数
> > 我没加?
> >
> >
> 
感谢大家回复,今天我又把之前的 gcc 全部推倒,重新编译

下午的时候发现了问题所在,不在 gcc 和 glibc 上,是 binutils 出了问题,
binuitls 的参数应该是这样:
../configure --target=arm-none-linux-gnueabi \
--prefix=/usr/local/arm/4.6.3/ \
--with-sysroot=/usr/local/arm/4.6.3/arm-none-linux-gnueabi/

指定了一个根目录。我以前还以为 --with-sysroot 这个参数是 gcc 给交叉编译
专门设的,原来 bintuils 也有

链接工具重新指定了根目录之后,就不会跑到系统库下面去寻找了。倒是之前只有
g++ 出问题,gcc 依然能正常使用的情况,倒是变得有些莫名其妙起来。明明没有
指定库目录,gcc 居然可以找到正确的库文件,让人费解


-- 
ubuntu-zh mailing list
ubuntu-zh@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh

Reply via email to