[Ubuntu-zh] 请问编译gcc的时候怎么指定库文件目录

hooxin firefoxmmx firefoxmmx在gmail.com
星期三 三月 7 01:43:29 UTC 2012


临时的用-L路径 ,全局修改/etc/ld.so.conf 在ldconfig


在 2012年3月7日 上午9:26,吴亚杰 <yajie.wu在hotmail.com>写道:

>
> 你可以在/etc/ld.so.conf文件中加入你那个库的路径
> 再运行ldconfig。
> 这样在编译时就会去那个库的路径下查找
>
> > Date: Tue, 6 Mar 2012 23:48:22 +0800
> > From: amankwah7在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来链接。
> >
> > --
> > ubuntu-zh mailing list
> > ubuntu-zh在lists.ubuntu.com
> > https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
>
> -------------- 下一部分 --------------
> 一个HTML附件被移除...
> URL: <
> https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20120307/5e03a015/attachment.html
> >
> --
> ubuntu-zh mailing list
> ubuntu-zh在lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
>
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: <https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20120307/60d86955/attachment.html>


关于邮件列表 ubuntu-zh 的更多信息