当前位置:首页 » 编程软件 » 交叉编译库路径

交叉编译库路径

发布时间: 2022-09-19 02:42:27

1. gcc交叉编译怎么找头文件及lib库的

是在specs里面读取的路径信息。
命令行中键入 gcc -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --ver
bose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libe
xecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-langu
ages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --
enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-
awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-thre
ads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptio
ns --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

注意“--prefix=/usr” 以及“--libdir=/usr/lib ”
表示gcc ld as 等可执行文件安装在/usr/bin,而libc.a 等文件是在/usr/lib中。
压缩交叉编译器时,也是要解压缩在在--prefix 指定的目录下。
比如 下载了arm-linux 的交叉编译器cross-3.3.2.tar.bz2,解压缩之后,运行 arm-linux-gcc -v
得到 --prefix=/usr/local/arm。那么就要把 bin lib 等所有的文件和文件夹到/usr/local/arm目录下。
否则到时候运行arm-linux-gcc hello.c会提示找不到stdio.h 或者 lib.so.6 等

HOWTO Use the GCC specs file

About Specs file
The "gcc" program invoked by users is a convenient front-end driver executable which will invoke other programs in the background such as cc1, as or ld to do its work according to the command line parameter given. A specs file is plain text used to control the default behavior for the "gcc" front-end. The specs file is usually built-in but for flexibility purposes, it can be overridden with an external version.
Basic Specs file modifications
CC will proce a specs file via the following command.
gcc -mpspecs > specs
You may use a text editor of your choice to inspect it. It may be confusing at first, but there are many places of interest. To use the specs file, invoke gcc with -specs= or place it at "/mingw/lib/gcc/mingw32//specs" to make GCC use it by default, where refers to the GCC version installed.
Adding include directories to the search path
& #160;he *cpp: section should be modified. It contains the following by default:
*cpp:
%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}
If "z:\libx\include" needs to be added to the GCC includes search path, it should be changed to the following
*cpp:
%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} -I/z/libx/include
Adding lib directories to the search path
& #160;he *link_libgcc: section should be modified. It contains the following by default:
*link_libgcc:
%D
& #160;f "z:\libx\lib" needs to be added to the GCC library search path, it should be changed to the following
*link_libgcc:
%D -L/z/libx/lib

2. 如何进行Qt应用程序的交叉编译

首先得把我们在X86机上调好的程序进行交叉编译,如果在X86上都没有通过的话。。那就不用交叉编译了,(肯定是通不过的),还是到正题吧,设置好环境变量,我们用以用echo 来查看环境变量,echo $TMAKEPATH ,如果返回的不是.../qws/linux-arm-g++ 的字符的话,我们一定得从新设置,

export TMAKEPATH=/tmake 的安装路径/qws/linux-arm-g++ ,同时QTDIR一定得要指定QTE的安装路径,设置过程如下:

export QTDIR=...../qt-2.3.7

以上环境设置好后,我们可以使用tmake来生成Makefile,注意这里我们是用tmake,而不是用qmake(注意),tmake工具在tmake包里面。 具体做法,我们可以在命令行下打:

tmake -o Makefile 工程名.pro

这样我们就新生成了一个Makefile文件,下一步,我们要打开这个文件,做一些小的修改

1: 将LINK=arm-linux-gcc 改为:LINK=arm-linux-g++

2:将LIBS=$(SUBLIBS) -L$(QTDIR)/lib -lm -lqte这句话改为:

LIBS=$(SUBLIBS) -L/opt/gcc-2.3.2-glibc-3.3.2/lib -L$(QTDIR)/lib -lm -lqte

加上你的交叉编译的库。

最后我们可以make了,一个可以在您的板子上可以运行的二进制文件产生了。linux

3. 交叉编译链应该安装到哪个目录下

创建目录以及环境变量
在当前用户目录下创建target-project文件夹,在该文件夹下创建mips-mole文件夹,在mips-mole文件夹下创建三个文件夹:build-tools,kernel,tools,最后,在build-tools文件夹下创建build-gcc,build-boot-gcc,build-glibc,build-binutils文件夹。命令如下:
$ cd ~
$ mkdir -p ./target-project/mips-mole/{kernel/,tools/,build-tools/{build-gcc,build-boot-gcc,build-glibc,build-binutils}}
$ tree ./target-project/mips-mole/

观察目录结构,如下图:

使用脚本构建环境变量,脚本内容如下图:

注意修改/home/用户名,修改正确后,使用source使脚本生效
$ cd target-project
$ chmod +x mips.sh
$ source mips.sh

可以使用echo査看相关变量名以观察环境变量是否生效。
最后把linux-2.6.38.tar.bz2下载放置在kernel文件夹下,binutils-2.22.tar.gz,gcc-4.6.2.tar.gz,glibc-2.14.tar.gz,glibc-ports-2.14.tar.gz,gmp-5.0.4.tar.gz,mpc-0.9.tar.gz,mpfr-3.0.1.tar.gz下载放置在build-tools文件夹下。

4. linux下用交叉编译器编译时,已经指定了库的路径跟库的名字,可是还是报错找不到库。

看起来它不是个库,倒像是个可执行程序
一般so都放在lib这样的目录下,你这个是bin,而且和它在一起的都是可执行程序,并且它没有so后缀名。

5. 交叉编译时,如何链接指定路径下的库

在整个工程的configure.in文件中加入如下代码:
#configure.in
if test x$CC = xgcc; then
#AC_PATH_PROG(BLKID, blkid, [], [$PATH:/sbin])
#AC_PATH_PROG(VOLID, vol_id, [], [$PATH:/lib/udev])
AC_MSG_WARN($BLKID --------------------------------------) #code only for test
AM_CONDITIONAL(MY_CROSS_COMPILE,false)
else
#AC_PATH_PROG(BLKID, blkid, [], [/home/user-name/ltib/rootfs/sbin])
#AC_PATH_PROG(VOLID, vol_id, [], [/home/user-name/ltib/rootfs/lib])
AC_MSG_WARN($BLKID ++++++++++++++++++++++++++++++++++++++) #code only for test
AM_CONDITIONAL(MY_CROSS_COMPILE,true)
fi

在需要blkid库的Makefile.am文件中
if MY_CROSS_COMPILE
AM_CPPFLAGS = -include $(top_builddir)/config.h -I ../include \
-DLOCALEDIR=\"$(localedir)\" -I /home/user-name/ltib/rootfs/usr/include
AM_CFLAGS = -fsigned-char -I /home/user-name/ltib/rootfs/usr/include
else
AM_CPPFLAGS = -include $(top_builddir)/config.h -I ../include \
-DLOCALEDIR=\"$(localedir)\"
AM_CFLAGS = -fsigned-char
endif

lib_mount_la_LIBADD = $(LDADD_common)
LDADD_common =

if MY_CROSS_COMPILE
LDADD_common += -L$(LTIB_PATH)/rootfs/usr/lib -lblkid -luuid
else
LDADD_common += -lblkid -luuid
endif

6. 如何交叉编译开源库

所谓的搭建交叉编译环境,即安装、配置交叉编译工具链。在该环境下编译出嵌入式Linux系统所需的操作系统、应用程序等,然后再上传到目标机上。
交叉编译工具链是为了编译、链接、处理和调试跨平台体系结构的程序代码。对于交叉开发的工具链来说,在文件名称上加了一个前缀,用来区别本地的工具链。例如,arm-linux-表示是对arm的交叉编译工具链;arm-linux-gcc表示是使用gcc的编译器。除了体系结构相关的编译选项以外,其使用方法与Linux主机上的gcc相同,所以Linux编程技术对于嵌入式同样适用。不过,并不是任何一个版本拿来都能用,各种软件包往往存在版本匹配问题。例如,编译内核时需要使用arm-linux-gcc-4.3.3版本的交叉编译工具链,而使用arm-linux-gcc-3.4.1的交叉编译工具链,则会导致编译失败。
那么gcc和arm-linux-gcc的区别是什么呢?区别就是gcc是linux下的C语言编译器,编译出来的程序在本地执行,而arm-linux-gcc用来在linux下跨平台的C语言编译器,编译出来的程序在目标机(如ARM平台)上执行,嵌入式开发应使用嵌入式交叉编译工具链。

工具/原料
电脑系统:win7系统。虚拟机系统:workstation6.5 。虚拟机安装的linux版本:fedora9.0。内核:linux2.6.25 。
方法/步骤
1
我使用的交叉编译工具链是arm-linux-gcc-4.4.3,把它放在linux系统的路径是图一

2
在linux系统的路径/home/song/share下放了交叉编译工具链arm-linux-gcc-4.4.3的压缩包,另一个版本的不用。有的人可能会问到怎么把这个压缩包弄到虚拟机的linux的系统的,我是通过samba服务从主机复制到虚拟机的,这里的share文件夹就是我samba服务器的工作目录,多了不说,这不是重点。
然后通过命令mkdir embedded 建立一个arm-linux-gcc的安装目录,如图二所示。当然安装路径和目录名称“embedded”可以依自己的喜好而定。
步骤阅读
然后通过命令将share文件夹下的arm-linux-gcc-4.4.3.tar.gz复制到这里的embedded文件夹下, 当然这里你也可以不进行这一步我这是为了方便以后管理,将arm-linux-gcc安装到embedded文件夹下,方便以后寻找。

然后使用tar命令:tar zxvf arm-gcc-4.4.3.tar.gz将embedded文件夹下的arm-linux-gcc-4.4.3.tar.gz解压缩安装到当前目录下

执行完解压缩命令,就已经将交叉编译工具链arm-linux-gcc-4.4.3安装到linux系统上了,这里默认安装到了图六所示的路径上。

接下来配置系统环境变量,把交叉编译工具链的路径添加到环境变量PATH中去,这样就可以在任何目录下使用这些工具。 vi /etc/profile 编辑profile文件,添加环境变量。

在profile中的位置处,添加图八所示的红线标注的一行,路径就是图六中的红线标注的路径后面加上/4.4.3/bin。

图八中的路径一定是你自己的安装路径,可以使用pwd命令查找一下那个bin目录的路径。添加完路径后,保存退出。接下来使用命令:source /etc/profile,是修改后的profile文件生效,如图九所示。

然后,使用命令:arm-linux-gcc -v查看当前交叉编译链工具的版本信息,如图九中的红线标注第③行所示。很明显 可以看到,如果不执行第②步,则查看版本信息不成功。
然后验证交叉编译工具链是否安装成功并且可以使用,如图九所示,随便找一个目录编辑一个hello源代码。

编辑好hello.c文件后,保存退出。然后使用交叉编译器对hello.c进行编译,并生成可执行文件hello

这里生成的hello文件并不能像gcc编译出来的文件那样直接使用“./hello”命令执行并显示内容 因为它是一个二进制文件,只能下载到开发板上执行!

至此,搭建交叉编译环境步骤结束。

7. arm-linux交叉编译器的路径设置问题,怎么办

尚观Linux入门基础课程 http://you.video.sina.com.cn/a/1544927-1320045357.html

Linux学习方法二-----尚观入学前免费Linux课程 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11620270
Linux学习方法之三---...学前免费Linux基础课程 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11621587
Linux最佳入门教程六-RHEL5安装 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11633451
linux最佳入门系列-bash编程基础 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#12155782
尚观讲座之C语言指针 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#14072212
Linux下J2EE服务器配置与集群-尚观讲座。http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#14675886
Linux安全机制,尚观Linux培训 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11619396
尚观linux安全DDOS攻击防范(一)http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#7145242
Linux最佳入门教程三 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11632447
Linux最佳入门教程四 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11631234
Linux最佳入门教程五 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11631388
Linux最佳入门教程五-RHEL4安装(一) http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11632917
Linux最佳入门教程五-RHEL4安装(二) http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=1544927&uid=1320045357&t=1#11631876
Linux嵌入式开发视频之C语言基础http://you.video.sina.com.cn/a/2144683-1320045357.html

1.类型运算符表达式http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16566482
3.函数与程序结构2 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16566780
5.结构体联合体位字段3 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16561239
5.结构体联合体位字段2 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16561197
5.结构体联合体位字段1 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16561159
4.数组与指针3 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16566908
4.数组与指针2 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16566864
2.控制流2 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16560817
3.函数与程序结构1 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16566668
4.数组与指针1 http://you.video.sina.com.cn/pg/topicdetail/topicPlay.php?tid=2144683&uid=1320045357&t=1#16561009

热点内容
百度云解压无法预览 发布:2025-04-16 01:46:49 浏览:367
hsqldb数据库 发布:2025-04-16 01:46:45 浏览:727
苹果xs和安卓5哪个好 发布:2025-04-16 01:46:12 浏览:902
萤石c5c怎么配置有线连接 发布:2025-04-16 01:39:16 浏览:455
潮主解压码 发布:2025-04-16 01:26:20 浏览:609
license文件夹 发布:2025-04-16 01:16:26 浏览:253
怎么给笔记本提升配置 发布:2025-04-16 01:15:46 浏览:186
java接口抽象 发布:2025-04-16 01:15:03 浏览:196
虚拟云服务器s 发布:2025-04-16 00:59:54 浏览:276
安卓手机如何同屏到ipad 发布:2025-04-16 00:39:57 浏览:352