URN Logo
UNIX Resources » Linux » China Linux Forum » CPU 与 编译器 » 4 » 编译好gcc后,gcc的默认库路径如何设置?
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
编译好gcc后,gcc的默认库路径如何设置?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Subject: 编译好gcc后,gcc的默认库路径如何设置?
Author: baishaolin    Posted: 2006-04-14 16:03    Length: 194 byte(s)
[Original] [Print] [Top]
现在我编译好了gcc-4.0.1,但是库路径总是找不对。 我试着设置了LD_LIBRARY_PATH, 在编译的时候也用过-L指定新的库路径,但是gcc总是先 找/usr/lib目录下。还请大侠们支招!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: EricFisher    Posted: 2006-04-14 16:20    Length: 702 byte(s)
[Original] [Print] [Top]
在编译binutils和gcc时,尝试一下使用这个选项:
--with-sysroot=dir
Tells GCC to consider dir as the root of a tree that contains a (subset of) the root filesystem of the target operating system. Target system headers, libraries and run-time object files will be searched in there. The specified directory is not copied into the install tree, unlike the options --with-headers and --with-libs that this option obsoletes. The default value, in case --with-sysroot is not given an argument, is ${gcc_tooldir}/sys-root. If the specified directory is a subdirectory of ${exec_prefix}, then it will be found relative to the GCC binaries if the installation tree is moved.

[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: baishaolin    Posted: 2006-04-14 16:49    Length: 530 byte(s)
[Original] [Print] [Top]
EricFisher:你好! 我可能没有说清楚。我现在已经编译好并安装了gcc, 用新生成的gcc编译hello.c的时候, 会出现
/usr/lib/crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:71: undefined reference to `__libc_csu_fini'
../sysdeps/i386/elf/start.S:72: undefined reference to `__libc_csu_init'
../sysdeps/i386/elf/start.S:81: undefined reference to `__libc_start_main'

/usr/lib/crt1.o是原来的库,现在的新crt1.o库在其他的目录下,我怎么能够让gcc运行的时候就能正确定位lib库的位置?
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: EricFisher    Posted: 2006-04-14 21:34    Length: 364 byte(s)
[Original] [Print] [Top]
试试这个:
“You can prevent GCC from searching any of the default directories with the -nostdinc option. This is useful when you are compiling an operating system kernel or some other program that does not use the standard C library facilities, or the standard C library itself. -I options are not ignored as described above when -nostdinc is in effect”
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: canopy    Posted: 2006-04-14 23:12    Length: 26 byte(s)
[Original] [Print] [Top]
gcc -v
输出什么?
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: baishaolin    Posted: 2006-04-15 08:49    Length: 225 byte(s)
[Original] [Print] [Top]
gcc寻找共享库的时候, -I -L 指定的目录 要排在默认设置目录之后 才进行搜索。 我不知道怎么改默认路径。我用gcc -print-search-file 命令,会打印出gcc 搜索的程序和库目录. 我只有将那些库搬到那些指定的目录中去。编译才通过。
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: baishaolin    Posted: 2006-04-15 09:34    Length: 686 byte(s)
[Original] [Print] [Top]
gcc -v 后 输出的内容
[root@localhost bin]# gcc -v
使用内建 specs。
目标:i386-redhat-linux
配置为:../gcc-4.0.1/configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --enable--long-long --host=i386-redhat-linux --with-system-zlib --enable-languages=c,c++,java : (reconfigured) ../gcc-4.0.1/configure --host=i386-redhat-linux --build=i386-redhat-linux --enable-multilib --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --enable--long-long --with-system-zlib --with-gcc-version-trigger=/usr/rtems/download/gcc-4.0.1/gcc/version.c --enable-languages=c,c++
线程模型:posix
gcc 版本 4.0.1
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: canopy    Posted: 2006-04-15 22:08    Length: 100 byte(s)
[Original] [Print] [Top]
你的问题有几个解决方法。其中比较简单的一个是:configure c 库和 gcc 时都使用同样的 --prefix
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: baishaolin    Posted: 2006-04-16 18:00    Length: 67 byte(s)
[Original] [Print] [Top]
编译gcc的时候,可以指定路径。但是我怎么指定库的路径?在哪步设定阿?
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: canopy    Posted: 2006-04-16 22:34    Length: 90 byte(s)
[Original] [Print] [Top]
我不清楚编一个native的gcc时怎么改变C库的路径,但是把他们都装到一起应该是可以的。
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: baishaolin    Posted: 2006-04-17 18:09    Length: 97 byte(s)
[Original] [Print] [Top]
编译gcc的时候 是不是就已经指定了库的路径了。库的路径根据编译gcc时的路径生成自己的路径阿
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: EricFisher    Posted: 2006-04-18 09:06    Length: 168 byte(s)
[Original] [Print] [Top]
gcc本身有自己的path search规则,库的安装路径是configure库时指定的,两者没有关系。
gcc参考上介绍,-nostdinc可以禁止gcc按照默认的规则进行搜索,不过我没有尝试过。
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: xhbdahai    Posted: 2006-09-12 13:36    Length: 128 byte(s)
[Original] [Print] [Top]
先使用-nostdinc和-nostdlib禁止掉所有的标准头文件和库文件的搜索目录,之后在命令行通过-I 和-L 指定你想要的头文件目录和库文件目录。
----
路漫漫兮修远兮,吾将上下而求索!
[Original] [Print] [Top]
Subject: Re: 编译好gcc后,gcc的默认库路径如何设置?
Author: leviathan    Posted: 2006-09-13 10:11    Length: 77 byte(s)
[Original] [Print] [Top]
用gcc --dumpspecs把specs列出来修改, 再用gcc --specs=<file>指定
----
菜鸟试飞中……
[Original] [Print] [Top]
« Previous thread
请问什么是交叉编译
CPU 与 编译器
4
Next thread »
pc上GCC编译器奇怪的坏了,那位高手指点一下
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 03:47:16, cost 0.045543909072876 ms.