交叉编译环境搭建
- 格式:doc
- 大小:1.07 MB
- 文档页数:14
ARM学习——建立交叉编译环境
ARM学习——建⽴交叉编译环境
在linux平台下,要为开发版编译内核,需要使⽴交叉编译⽴具链。
tiny6410使⽴的是arm-linux-gcc-4.5.1。
它默认采⽴armv6指令集,⽴持硬浮点运算。
以下是安装步骤:
1)将⽴件arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz复制到redhat 的⽴录/tmp⽴录下。
然后cd到该⽴录,执⽴解压命令:
注意:C后⽴是⽴个空格,并且C是⽴写的,它是英⽴单词“Change”的第⽴个字母,在这⽴是改变⽴录的意思。
执⽴该命令后,arm-linux-gcc被安装到/opt/FriendlyARM/toolschain/4.5.1 ⽴录。
2) 把编译器路径加⽴到系统环境变量,运⽴命令
编辑/root/.bashrc ⽴件,在最后⽴⽴加⽴export PATH=$PATH:/opt/FriendlyARM/toolschain/4.5.1/bin。
如果在ubuntu10⽴⽴,就修改/etc/environment⽴件。
在PATH字符串⽴⽴添加上“:/opt/FriendlyARM/toolschain/4.5.1/bin”。
重启虚拟机。
如上图。
然后保存退出。
重新登录系统(不必重启机器,注销(logout)⽴下就可以了)。
重新登录后,在命令⽴输⽴arm-linux-gcc-v,出现以下信息就说明交叉编译环境安装成功了。
预备实验:交叉编译环境建立知识点储备:1、熟练掌握shell指令:sudo 、cd 、ls、tar、pwd、vim、source、export (阅读“Linux 系统命令及其使用详解”,完成附录一“Linux指令的随堂测试”)2、掌握添加环境变量的手段(参见附录二“关于在ubuntu下设置环境变量的三种方法”)3、掌握编写Makefile的方法(阅读“跟我一起写Makefile”,完成附录三的“Makefile的随堂测试”)4、关于64位ububuntu12.4系统安装32位依赖库的问题解答见附录四。
一、交叉编译的安装步骤:(cd 切换工作目录;pwd:查看当前目录路径;exit:退出root)1、将压缩包arm-linux-gcc-4.4.3.tar.gz存放在一个目录下,这个目录就是你等会解压缩的目录,以后这个目录就不能随便删掉了,我的存放路径是 /home/song/software,如下图,记住这个路径,等会还会用到。
(cd song后cd software)2、使用tar命令:tar -zxvf arm-linux-gcc-4.4.3.tar.gz将software文件夹下的arm-linux-gcc-4.4.3.tar.gz解压缩安装到当前目录下如下图通过下图可以看到解压成功了,并且解压后的文件存放在了/home/song/software/opt/FriendlyARM/toolschain/4.4.3文件夹下,如下图所示,这个存放路径可得记住,如下图(jack123@ubuntu:~/song/software/opt$ cd FriendlyARMjack123@ubuntu:~/song/software/opt/FriendlyARM$ cd toolschainjack123@ubuntu:~/song/software/opt/FriendlyARM/toolschain$ cd 4.4.3jack123@ubuntu:~/song/software/opt/FriendlyARM/toolschain/4.4.3$ lsjack123@ubuntu:~/song/software/opt/FriendlyARM/toolschain/4.4.3$ pwd/home/jack123/software/opt/FriendlyARM/toolschain/4.4.3)2:/home/jack123/software/opt/FriendlyARM/toolschain/4.4.3/bin3、接下来配置系统环境变量,把交叉编译工具链的路径添加到环境变量PATH中去,这样就可以在任何目录下使用这些工具。
qt 源码交叉编译Qt是一款一流的跨平台应用程序开发框架。
由于 Qt 提供了非常具有竞争力的开发效率,易于开发者上手的API 设计,“Write Once, Run Anywhere” 的特性以及一系列高效、易于维护的组件等等优点,因而已经被广泛应用在各类软件开发类型中。
在使用 Qt 进行嵌入式开发时,我们经常需要将 Qt 源码交叉编译到目标平台。
Qt 源码交叉编译的过程远不是一件易事,需要开发者对开发环境有深入的了解。
在本文中,我们将为大家讲解如何对 Qt 源码进行交叉编译。
一、搭建交叉编译环境在进行 Qt 源码交叉编译前,我们需要先搭建好交叉编译的环境。
根据目标平台的不同,搭建环境的方法也会有所不同。
如果您需要将 Qt 编译到 ARM 平台上,可以尝试使用工具链进行交叉编译;如果您需要将 Qt 编译到MIPS 平台上,应该使用 Qemu 虚拟机进行交叉编译。
无论你选择哪种方式,您都需要确保您的开发环境中所有必要的库都已经安装到了系统中。
例如,如果您需要对 Qt 进行静态编译,您需要在开发环境上安装 libxcb-static、libxkbcommon-static 和 libinput-static 等库。
在搭建好 environment 后,我们需要对自己所使用的工具链进行相应的配置。
首先,您需要设置您的编译器、链接器、构建工具等等配置信息,并且需要确保这些配置信息均已经添加到 PATH 路径中。
接着,您可以通过设置以下环境变量来使得交叉编译环境正常运行:export TARGETMACH=arm exportQMAKE_CXX=/path/to/YOUR_ARCH-g++ export QMAKE_LINK=/path/to/YOUR_ARCH-g++ exportQT_ARCH=arm exportCROSS_COMPILE=/path/to/YOUR_ARCH-以上的环境变量是指定了目标平台架构($TARGETMACH)、编译器及链接器($QMAKE_CXX 和$QMAKE_LINK)、构建的目标架构($QT_ARCH),以及编译时需要的交叉编译工具链($CROSS_COMPILE)。
随着消费类电子产品的大量开发和应用和Linux操作系统的不断健壮和强大,嵌入式系统越来越多的进入人们的生活之中,应用范围越来越广。
在裁减和定制Linux,运用于你的嵌入式系统之前,由于一般嵌入式开发系统存储大小有限,通常你都要在你的强大的pc机上建立一个用于目标机的交叉编译环境。
这是一个由编译器、连接器和解释器组成的综合开发环境。
交叉编译工具主要由binutils、gcc 和glibc 几个部分组成。
有时出于减小libc 库大小的考虑,你也可以用别的c 库来代替glibc,例如uClibc、dietlibc 和newlib。
建立一个交叉编译工具链是一个相当复杂的过程,如果你不想自己经历复杂的编译过程,网上有一些编译好的可用的交叉编译工具链可以下载。
下面我们将以建立针对arm的交叉编译开发环境为例来解说整个过程,其他的体系结构与这个相类似,只要作一些对应的改动。
我的开发环境是,宿主机i386-redhat-7.2,目标机arm。
这个过程如下1. 下载源文件、补丁和建立编译的目录2. 建立内核头文件3. 建立二进制工具(binutils)4. 建立初始编译器(bootstrap gcc)5. 建立c库(glibc)6. 建立全套编译器(full gcc)下载源文件、补丁和建立编译的目录1. 选定软件版本号选择软件版本号时,先看看glibc源代码中的INSTALL文件。
那里列举了该版本的glibc编译时所需的binutils 和gcc的版本号。
例如在glibc-2.2.3/INSTALL 文件中推荐gcc 用2.95以上,binutils 用2.10.1 以上版本。
我选的各个软件的版本是:linux-2.4.21+rmk2binutils-2.10.1gcc-2.95.3glibc-2.2.3glibc-linuxthreads-2.2.3如果你选的glibc的版本号低于2.2,你还要下载一个叫glibc-crypt 的文件,例如glibc-crypt-2.1.tar.gz。
嵌入式操作系统实验报告队友:张圣苗亚实验内容1、准备工作工作:安装virtualbox虚拟机工具,并安装ubuntu10.10系统、增强型工具,实现共享文件夹的自动挂载。
2、利用crosstool提供的脚本安装和相关资源编译面向的ARM的GCC工具。
详细内容1:安装虚拟机软件和虚拟机时要完成的主要步骤有:安装virtualbox,建立一台虚拟机,分配内存和硬盘,指定共享文件夹(主机和虚拟机可共同操作),指定操作系统镜像文件路径(相当于光盘,第一次启动时安装),安装虚拟操作系统,安装增强工具包,实现共享文件夹的自动挂载。
有几点需要注意:1、虚拟硬盘尽量分配大一些,之后再扩就比较麻烦。
2、共享文件夹不要有中文路径,不然挂载后看不到中文名称文件。
3、安装操作系统时,不能断网,需要下载各种资源,不然会异常。
详细内容2:安装gcc-4.1替换操作系统中的gcc-4.4.5,用它编译交叉编译器gcc-3.4.5和库文件glibc-2.3.2、gdb-6.5。
为了完成这样的目标,我们需要安装与脚本相关的工具,需要修改crosstool中的配置文件arm.dat以指定编译的目标位arm-linux。
需要修改crosstool中的脚本文件,指定编译的源文件和目的文件夹(后来建立),指定配置文件为gcc-3.4.5-glibc-2.3.2.dat,在该配置文件中,指定了交叉编译器和调试器、C库的版本。
最后运行脚本,实现了对GCC工具包的安装,包括gcc预处理器、汇编器、编译器、链接器、调试器、反汇编工具等等。
整个实验中我们需要的资源是crosstool-0.43.tar、gdb-6.5.tar、linux-2.6.8.tar,将放置在共享文件夹的crosstool工具拷贝到主文件夹下并解压,将gbd和linux文件拷贝到crosstool文件夹,拷贝linux-2.6.8.tar是因为编译时需要内核文件。
实验步骤实验准备:在实验准备中,在安装完增强工具包(安装vmware tools实现与XP文件共享)并重启之后,需要实现对共享文件夹的自动挂载,只需要修改etc目录中的配置文件rc.local,rc.local是很多linux系统管理员的偏爱,因为凡是需要随系统自动启动的服务、程序等,都可以放在里面。
alsalib 交叉编译
摘要:
1.交叉编译简介
2.alsalib 交叉编译概述
3.环境搭建
4.编译过程
5.测试与验证
6.总结
正文:
交叉编译是在一个平台上编译另一个平台的程序,通常用于开发嵌入式系统。
alsalib 是一个alsa 库的交叉编译版本,适用于嵌入式系统开发。
本文将详细介绍alsalib 的交叉编译过程。
首先,我们需要搭建交叉编译环境。
为此,我们需要准备以下工具和软件:
- 一台具有交叉编译能力的计算机(例如,Linux 系统)
- 目标平台的开发工具链(交叉编译器、链接器等)
- alsalib 源代码
在搭建好环境后,我们可以开始进行编译。
编译过程主要分为以下几个步骤:
1.配置编译器:根据目标平台和开发工具链,配置交叉编译器。
例如,在Linux 系统上使用arm-linux-gnueabihf-gcc 作为交叉编译器。
2.编译alsalib:使用交叉编译器编译alsalib 源代码。
这一步可能需要安装一些依赖库,例如libsndfile、libsamplerate 等。
3.编译alsalib 的动态链接库:为了在目标平台上使用alsalib,我们需要编译其动态链接库。
这可以通过使用`-fPIC`选项来完成。
4.安装alsalib:将编译好的alsalib 及其动态链接库安装到目标平台。
5.测试与验证:在目标平台上运行alsalib 提供的示例程序,以验证交叉编译是否成功。
总之,通过以上五个步骤,我们可以完成alsalib 的交叉编译。
交叉编译环境的建立2009-10-14 20:36:03建立arm-linux-gcc交叉编译环境一。
准备工作安装linux环境(我的是RED_HAT9 linux2.2的内核)下载交叉编译文件包 cross-2.95.3.tar.bz2二。
建立目录1.建立交叉编译环境目录/usr/local/arm/(一定要在这个目录下否则会报错)三。
安装交叉编译环境1.复制安装包到目录下cp /mnt/hgfs/share/cross-2.95.3.tar.bz2 /usr/local/arm/(注:我这里是用windows下载的压缩包,然后用VM共享的,我的linux网卡还没配置所以 linux环境下下载,呵呵)2.解包交叉编译文件cd /usr/local/arm/tar jxvf cross-2.95.3.tar.bz2(正常的话会在arm目录下看到2.95.3这个文件夹)四。
配置环境变量1.修改bashrc文件cd /etc/vi bashrc(在文件最后一行添加环境变量代码export PATH=/usr/local/arm/2.95.3/bin:$PATH) 2.保存退出命令模式下 wq3.重新启动linux。
五。
编写测试代码1.建立源文件vi hello.c编写如下代码(也可以编写其他C代码):#include<stdio.h>int main(){printf("Hello,world!\n");return 0;}2.保存退出wq六。
测试编译环境arm-linux-gcc -o hello hello.c file hello执行后出现如下信息表示通过:hello: ELF......。
树莓派交叉编译环境搭建拿树莓派是想⽤来做开发,⽽树莓派那么⽕更多的原因是可以DIY,开发和DIY还是有点区别的,⽽国内外论坛多数的资料还是在DIY这块,系统的进⾏开发找到的不是很多。
打算⽤树莓派移植Qt和OpenCV看看在图像处理⽅⾯能否做点事情,⼊门的第⼀个问题就是建⽴交叉编译平台,搜索了点资料,发现⼀篇说的⽐较详细,英⽂⽂章,这⾥全⽂转载。
In this blog entry the setup of a cross-compiling development environment for the Raspberry Pi will be demonstrated. This will include the (available from github)We will finally write a simple Hello World program on our Kubuntu virtual machine (VM), compile it using the cross compiler and then deploy it onto our Raspberry Pi board to run it.I’m going to assume that you have alreadyand that you have Ubuntu / Kubuntu Linux installed either has a host OS or on your desktop PC.A remote debugging tutorial; which I consider to be the continuation of this tutorial, can be found .So what is a cross compiling toolchain and why use one ?A native compiler such as the default gcc tool on Kubuntu is a compiler that runs on an Intel machine, as well as creates binaries intended to be run on an Intel machine. i.e it creates binaries for the same type of machine that it runs on. Similarly the GCC tool in the RPi’s Raspbian Linux OS is intended to run on an ARM machine as well as creates binaries for an ARM machine.A cross compiler such as the “arm-linux-gnueabihf-gcc” that we will use is able to run on an Intel machine but creates binaries for an ARM machine. In other words, it runs on one architecture and creates binaries for another. This allows us to develop and compile our programs on our Desktop PC but when it comes to deploying the binaries we deploy them and run them on the Raspberry Pi.So why use a Cross-compiler instead of developing our code and compiling it natively on the Raspberry Pi itself? After all, the Raspberry Pi has a native GCC compiler. We can also use code editors such as nano or vi from the command line (remotely over SSH) or GUI programs such as Geany (remotely over VNC).The main case for cross-compilation over native compilation (develop and compile on the RPi itself) is that it tends to be faster. Remember the RPi board may be fast compared to a microcontroller…but its still has limited RAM resources and is pretty slow compared to an average desktop computer….Also you have a myriad of development tools that you can use on your desktop PC that you simply can’t use on the Raspberry Pi; such as the Eclipse IDE.Now that I’ve explained the why…let’s get started!Downloading and Setting Up the Cross Compiling ToolchainOpen a terminal window on your desktop side Kubuntu/Ubuntu Linux OS and type the following command: “sudo apt-get install git“. This will install the GIT tool on your desktop linux box which in turn will enable us to download / clone the cross compiling toolchain from .If you’re running a 64-bit Ubuntu/Kubuntu Linux OS you will probably also want to install the 32-bit library/header files. Since the cross compiler will need them to properly run. You can do this by typing “sudo apt-get install ia32-libs“. Again this step is only required if you are running a 64-bit Linux OS. Once git is installed, create a “raspberrypi” directory in your home directory by typing “mkdir raspberrypi“.Go to the raspberrypi directory by “cd raspberrypi” and then type: “sudo git clone git:///raspberrypi/tools.git“This command will download (clone) Raspbian’s official cross compiling toolchain from Github. The command will take a few minutes to complete its task.When the previous command completes, navigate to “/home/halherta/raspberrypi/tools/arm-bcm2708″ using “cd ~/raspberrypi/tools/arm-bcm2708” on your Deskop Linux OS.In the arm-bcm2708 folder you’ll see three other folders each containing a separate toolchain:1. arm-bcm2708-linux-gnueabi2. arm-bcm2708hardfp-linux-gnueabi3. gcc-linaro-arm-linux-gnueabihf-raspbianOf those three we will use the third one. The next step is to add the directory containing the binary files of the third toolchain “gcc-linaro-arm-linux-gnueabihf-raspbian” to the PATH environment variable in linux. This way we can access the toolchain’s binary files from anywhere on our computer. We will do this by adding an “export PATH” command to the bottom of the .bashrc and .profile files in the home directory.In a terminal window (on your Desktop Linux OS) type “cd ~/“ to point to the home directory, then type “nano .bashrc“. This will open the .bashrc file in a command line based editor called nano. Go to the bottom of the .bashrc file using the down arrow key. Then type the following command:“export PATH=$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin”Then hit Ctrl+x to exit. You will be prompted to save changes. Say yes and hit “Enter”.Similarly in our home directory type “nano .profile“. This will open the .profile file in the command line editor nano. Go to the bottom of the .profile file using the down arrow key. Then type the same command again:“export PATH=$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin”Then hit Ctrl+x to exit. You will be prompted to save changes. Say yes and hit “Enter”.Now restart your machine. (You probably could just log out and log in again)Ideally you need to export the toolchain’s directory path to the PATH variable in either the .bashrc or the .profile files. This didn’t work for me. If it works for you thats great.When you log-in into your desktop Linux OS, open a new console window and type: ” arm-linux-gnueabihf-gcc -v”. If you were successful you should see output similar to that in Figure 1. Congratulations! you just installed Raspbian’s official cross compiling toolchain on your Desktop PC / Virtual Machine!Figure 1. Cross Compiling Toolchain successfully installed and accessible from anywhere within your Desktop side Linux OSDownloading and Setting Up EclipseThe Next step is to download and install Eclipse. Unfortunately as of this writing the apt-get repositories have yet to contain the latest Eclipse build…Eclipse Juno. So we will not be using the apt-get package manager. Instead we will download the latest Eclipse IDE from the web using a web browser. Before we can run eclipse, we need to ensure that we have a Java runtime environment installed; since eclipse relies heavily on Java. We can do this with the following command: “sudo apt-get install openjdk-7-jre“Go to the link provided below and download the linux version of the Eclipse IDE (Juno) for C/C++. Download the 32-bit version of the IDE if you’re running a 32-bit Linux OS or download the 64-bit version of the IDE if you’re running a 64-bit Linux OS.Link:If you’re not sure whether you’re running a 64-bit or 32-bit Linux OS, open a terminal window and type” uname -a“. If the output of that command contains “i686″ or “i386″, you’re running a 32-bit Linux OS. If in the output you see “x64″ then you’re running a 64-bit Linux OS.The next step is to extract the “eclipse” folder into our home directory from the eclipse-cpp-juno-linux-gtk.tar.gz compressed file. This can be easily done using the Dolphin File Manager. Navigate to the directory in which “eclipse-cpp-juno-linux-gtk.tar.gz” was downloaded. Click on the file. This will open a decompression tool. Click on extract and choose to extract to the /home/halherta directory. Alternatively open a new console and navigate to the directory containing the .gz file then type: “tar -xvzf eclipse-cpp-juno-linux-gtk.tar.gz -C ~/“. Either way you will end up having the eclipse directory created in your home directory. To start eclipse, go to the home directory “cd ~/” then ‘cd’ your way into the eclipse folder “cd eclipse” then type“./eclipse &“.If you have been following my series of tutorials from scratch and/or are running Kubuntu, you can enable starting eclipse from the start menu right click on the blue KDE start menu button and click on “Edit Applications”. This will open the KDE Menu Editor.Select on the “Development” tab in the right of the window and then click on the “new item” button. A message box will pop-up. Enter under “item name”: “Eclipse Juno for C/C++ Developers”. Then click on the “open file dialog” adjacent to the “command field” and select the eclipse binary which should be “/home/halherta/eclipse/eclipse”. Furthermore, click on the icon box. This will open an icon source box select the “other icon” option and then click on the browse button. Browse to the “/home/halherta/eclipse/” folder and then select the “icon.xpm” file.Figure 2. Choose “Other Icons” and hit “Browse” button to select “icon.xpm” file in the eclipse directoryAfter these changes the KDE Menu Editor window should look like the illustration shown in Figure 3.Figure 2. Choose “Other Icons” and hit “Browse” button to select “icon.xpm” file in the eclipse directoryFinally click on the “Save” button and then close the KDE Menu Editor. If you now navigate the KDE menu, you should find eclipse under “Applications->Development”. If you click on it the Eclipse IDE should start.Note if you’re running Ubuntu (without Unity…just gnome classic) you can right click on the “Applications Menu” and select “Edit Menu” to edit your gnome-based Ubuntu start menu and add to it an entry for eclipse in a similar manner as demonstrated above. And don’t ask me about Ubuntu Unity integration..I hate it.Creating a New Project in EclipseWhen Eclipse runs, it will first launch the workspace launcher. You will be prompted to choose a workspace directory. Accept the default. Feel free to check the “Use this as the default and do not ask again” option if you feel inclined to do so. (You can always switch/change the workspace directory by going to “File->Switch Workspace” ).Figure 4. Workspace launcherYou should then see a Welcome Tab (Figure 5). Click on the ‘x’ on the Welcome tab to close itFigure 5. Welcome Tab. Click on the ‘x’ in the tab to close itNow go to File->New->C++ Project. This will open the “C++ Project” window shown in Figure 6.Figure 6. C++ Project WindowType “HelloWorld” in the “Project Name” field. Under Project type select “Executable->Empty Project” Under “Toolchains” select “Linux GCC”. Then click on “Next” This should take you to the “Select Configurations” Window. Accept the defaults and click “Finish”.This should be the end of the basic project configuration. Your Eclipse Environment should look as shown in Figure 7.Figure 7. New Hello World Project initial setupNotice how this project does not have any source files so lets add one. Click on “File->New Source File”. This should open the “New Source File”window.Figure 8. New source File Window.Ensure that the “Source folder” and “Source file” fields include “HelloWorld” and “HelloWorld.cpp” respectively as shown in Figure 8 and click Finish. This will add a HelloWorld.cpp source file to our project. In the source file type the following basic C++ code:/** HellWorld.cpp** Created on: 2012-09-27* Author: halherta*/#include <iostream>using namespace std;int main (void){cout << "Hello RPi Development World !"<< endl;return0;}Save your project by clicking on “File->Save”.Now we will need to access the Project properties to ensure that the correct compiler (the Raspbian cross compiler) and its header and library files are being used. To do this select the “HelloWorld” folder/project in the project explorer and then click on project properties. This will open the “Properties for HelloWorld” window.Figure 9.First go to “C/C++ General -> Paths and Symbols” from the left hand side navigation bar. In the “Includes” Tab make sure that all the include pathsincluded in Figure 9 are added.Then go to the “Library Paths” and make sure that all the library paths in Figure 10 are added.Figure 10. Library Path for the Cross CompilerFinally go to “C/C++ Build -> Settings” (Figure 11) from the left hand side navigation bar. Under the “Tool Settings” Tab select “GCC C++ Compiler” for that Tab’s Navigation bar and ensure that the command field contains: “arm-linux-gnueabihf-g++”Similarly the command field for the “GCC C Compiler” should contain “arm-linux-gnueabihf-gcc”Similarly the command field for the “GCC C++ Linker” should contain “arm-linux-gnueabihf-g++”And finally the command field for the “GCC Assembler” should contain “arm-linux-gnueabihf-as.Figure 11. C/C++ Build->SettingsThen click on the Apply and OK buttons. At this point the Eclipse IDE is configured to utilize the Raspbian cross compiler.To build the project click on “Project->Build Project”. To clean the project click on “Project->Clean”. Figure 12 shows the Eclipse workspace with the HelloWorld program successfully cross compiled for the Raspberry PiFigure 12. HelloWorld program successfully compiled for Raspberry Pi.The binary file for our HelloWorld application resides in the “~/workspace/HelloWorld/Debug”. Lets go there via a console window with cd “cd~/workspace/HelloWorld/Debug/“. If we type in “ls -al” we’ll find that our Binary file is highlighted in green and is called HelloWorld. If I try to run it with “./HelloWorld” I get the following error message “cannot execute binary file“. Now if I type “file HelloWorld“, I get the following output: “HelloWorld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26,BuildID[sha1]=0xb37e6eaa466429d015cc334d55f5d46c97c9fc6c, not stripped“. This indicates that the HelloWorld Binary File was compiled for a 32-bit ARM machine and cannot run on an Intel Machine.Deploying the Binary file onto the Raspberry PiTo deploy the binary to the Raspberry Pi, make sure that the RPi board is powered and connected to your network. The next step is click on “Window->Show View->Other”. This will open a show view window. In this window select the “Remote Systems” folder and then select “Remote Systems Details” and press OK (Figure 13).Figure 13. Remote system viewIf the “Remote Systems Details” shows up in the bottom of the workspace, drag it such that its tab shares the same region as the project explorer tab as shown in Figure 14.Figure 14.Now right click in the “Remote Systems Detail” area and click on “New Connection”. In the “Select Remote System Type” window (Figure 15), select “SSH only” then click “Next”Figure 15.In the “Remote SSH Only System Connection” type in the IP address of the RPi in the “Host name” field and give the connection a valid name in the “Connection name” field. I typed “RaspberryPi”. Then click “Finish”.Figure 16.At this point a second device (Raspberry Pi) shows up in the “Remote Systems Detail” tab. Right click on the Raspberry Pi resource and click connect. You will be prompted to enter the username and password. Make sure that you utilize “username:pi” and “password:raspberry” (if you haven’t changed the default password). You may get a warning windows asking you if you are sure that you want to accept this connection. Affirm that you want to proceed with the connection. At this point you should be connected to your RPi from eclipseFigure 17.Right click on the Raspberry Pi resource again in the “Remote Systems Detail” tab and click on the “Show in Remote Systems View”. This will open a “Remote Systems” tab in the same region of the workspace. In this tab, one can navigate the root file systems of both the Kubuntu (local) OS and that of the Raspbian/Raspberry Pi.Locate the HelloWorld Binary file on our local desktop PC and drag it to the home directory on the Raspberry Pi. This effectively copies the Binary file to the home directory of the Raspberry Pi.Figure 18.Now right click on the SSH terminal icon under the Raspberry Pi icon in the “Remote Systems” and select “Launch Terminal” . This should launch a terminal window in the bottom of the Eclipse workspace (Figure 19). This is basically a console / terminal window connected to the Raspberry Pi via SSH.Figure 19.In the terminal window type “ls -al” to confirm that the “HelloWorld” binary indeed got copied into the home directory of the Raspberry Pi’s root file system. Then change the “HelloWorld” binary’s permission to make it executable: “chmod +x HelloWorld“Finally type “./HelloWorld“. You should see the output shown in Figure 19. :“Hello RPi Development World !”Congratulations You just developed and ran your first cross compiled application for the Raspberry Pi.!To remotely debug your applications on the Raspberry Pi from Eclipse, check out。
gcc linaro 交叉编译好的,以下是一篇关于gcc linaro交叉编译的文档,希望能够帮助到您:交叉编译是一种在一种架构上编译出适用于另一种架构的程序的技术。
在嵌入式系统开发、软件移植等领域中,交叉编译是非常重要的一项技能。
Linaro是一个由许多不同厂商支持的开源组织,它致力于简化麒麟操作系统(麒麟是用于基于Linux的系统的一套容器和包管理器)的开发和构建过程。
在本篇文章中,我们将介绍如何在Linaro环境下使用gcc进行交叉编译。
一、准备工作1. 安装Linaro环境:首先,您需要安装Linaro环境,以便能够编译适用于其他架构的程序。
2. 确定目标架构:在进行交叉编译之前,您需要确定目标架构(如x86、ARM等)。
3. 安装交叉编译工具链:根据目标架构,您需要安装相应的交叉编译工具链。
二、交叉编译步骤1. 编写代码:使用适用于目标架构的编程语言编写代码。
2. 配置环境变量:确保编译器、头文件等路径被正确添加到环境变量中。
3. 编译代码:使用gcc等交叉编译工具编译代码。
例如,对于ARM架构,可以使用以下命令进行编译:`arm-linaro-gcc -ooutput_file input_file`。
4. 生成可执行文件:编译成功后,生成适用于目标架构的可执行文件。
三、注意事项1. 确保目标架构与工具链匹配:在进行交叉编译时,确保目标架构与所使用的交叉编译工具链相匹配。
2. 调试信息:如果您需要调试生成的程序,请确保在编译时启用调试信息。
3. 链接库:如果您的程序需要链接库文件,请确保已正确安装并链接到目标架构的库文件。
四、实践案例下面是一个简单的实践案例,演示如何在Linaro环境下使用gcc 进行交叉编译:1. 编写一个简单的C程序(例如hello_world.c),并在终端中打开该文件。
2. 使用以下命令进行编译:`arm-linaro-gcc -o hello_world hello_world.c`。
在使用Qt Creator 进行交叉编译时,您需要配置Qt Creator 以使用Clang 编译器进行交叉编译。
下面是一般步骤的概述:安装Qt Creator:首先,确保您已经安装了最新版本的Qt Creator。
您可以从Qt 官网下载并安装适用于您的操作系统的版本。
安装Clang 编译器:安装适用于目标平台的Clang 编译器。
您可以从Clang 官网下载预编译的二进制文件,或者根据您的需求从源代码编译。
配置交叉编译工具链:在Qt Creator 中,您需要配置交叉编译工具链。
打开Qt Creator 并导航到“工具”->“选项”->“构建和运行”。
在“编译器”选项卡下,点击“添加”并选择“Clang”。
指定Clang 编译器的路径和名称。
确保提供正确的编译器二进制文件路径。
配置编译器选项和标志,以便与目标平台兼容。
配置交叉编译环境:在Qt Creator 中,您还可以配置交叉编译环境,以便为目标平台生成正确的二进制文件。
在“构建和运行”选项卡下,选择“Qt Versions”。
点击“添加”并指定适用于目标平台的Qt 版本。
确保提供正确的Qt 库路径和版本信息。
在“构建套件(Kit)”选项卡下,点击“添加”并创建一个新的构建套件。
选择之前配置的Clang 编译器和Qt 版本,以及其他必要的构建选项。
编写和构建项目:现在,您可以创建一个新的Qt 项目或打开现有的项目。
在项目设置中,选择之前配置的交叉编译构建套件。
然后,您可以编写代码并使用Qt Creator 构建项目。
构建过程将使用配置的Clang 编译器和交叉编译选项来生成适用于目标平台的二进制文件。
在交叉编译环境下编译libGLES(OpenGL ES库)需要注意配置适当的交叉编译工具链和编译选项。
下面是一个详细的步骤,演示如何交叉编译libGLES。
注意:实际的步骤可能因你的交叉编译目标平台、操作系统和工具链而异。
步骤:
1.获取交叉编译工具链:首先,你需要获取适用于目标平台的交叉编译工具
链。
这通常是由目标平台的供应商提供的,例如,对于ARM平台,可以使用ARM提供的交叉编译工具链。
2.设置环境变量:将交叉编译工具链添加到你的系统的PATH环境变量中,以
确保能够在终端中访问它。
3.获取libGLES源代码:下载libGLES的源代码,你可以从OpenGL官方网
站或其他资源库中获取。
4.配置交叉编译:进入libGLES源代码目录,并配置交叉编译环境。
使
用./configure或其他配置脚本,根据你的目标平台设置交叉编译工具链和选项。
5.编译libGLES:运行make命令来编译libGLES。
确保指定正确的交叉编译
工具链和目标平台。
6.安装或拷贝库文件:编译完成后,你可以将生成的库文件拷贝到目标平台
上,或者使用make install命令将其安装到指定的目标目录。
7.配置和使用:在目标平台上,确保正确配置和链接libGLES库,以便在应
用程序中使用OpenGL ES功能。
请注意,具体的配置和编译选项会因你的目标平台和操作系统而异。
在交叉编译libGLES之前,建议查阅相关文档和资源,以确保正确配置和编译过程。
交叉编译gdb使用摘要:一、交叉编译gdb概述1.交叉编译简介2.gdb的作用与重要性3.交叉编译gdb的必要性二、交叉编译gdb的准备工作1.环境搭建a.安装交叉编译工具链b.获取gdb源码2.配置编译选项a.选择适当的架构b.配置编译器参数三、交叉编译gdb的步骤1.编译gdb内核模块2.编译gdb用户态程序3.安装gdb四、使用交叉编译gdb进行调试1.准备工作a.编译并安装被调试程序b.设置交叉调试环境变量2.使用gdb进行调试a.运行被调试程序b.设置断点与调试命令c.查看与修改程序状态正文:一、交叉编译gdb概述交叉编译是在不同架构的机器上编译程序,以实现对目标架构机器的兼容。
GDB(GNU Debugger)是一款强大的调试工具,可以用于调试程序的执行过程,查找并解决程序中的错误。
在嵌入式开发中,由于目标硬件资源有限,通常需要使用交叉编译工具链来编译程序,这也包括gdb。
因此,掌握交叉编译gdb的使用对于嵌入式开发者来说尤为重要。
二、交叉编译gdb的准备工作为了进行交叉编译gdb,首先需要搭建一个适合交叉编译的环境。
这包括安装交叉编译工具链,例如arm-linux-gnueabihf-gcc,以及获取gdb源码。
在获取gdb源码之后,需要对其进行配置,选择适当的架构,并配置编译器参数。
三、交叉编译gdb的步骤在完成准备工作之后,可以开始进行交叉编译gdb。
首先,编译gdb的内核模块,然后编译gdb的用户态程序。
最后,将编译好的gdb安装到目标系统中。
四、使用交叉编译gdb进行调试要使用交叉编译gdb进行调试,首先需要编译并安装待调试程序。
接着,设置交叉调试环境变量,使被调试程序可以在目标硬件上运行。
然后,使用gdb运行被调试程序,设置断点与调试命令,查看并修改程序状态,以逐步排查并解决程序中的问题。
总之,交叉编译gdb是嵌入式开发过程中不可或缺的一环。
交叉编译环境搭建 一、Emdebian介绍 Emdebian vision In the Emdebian vision someone wishing to build a GNU / Linux based device would:
1. Port the linux kernel to their hardware (including writing any specific device drivers).
2. Select the prebuilt emdebian packages needed to support their application.
3. Package their application as Debian package(s) using Debian and Emdebian tools. 4. Build a root filesystem using Emdebian tools from the steps above.
Emdebian is involved in steps 2,3,4 above (there are far too many embedded device hardware variations to make prebuilt kernels practical).
Thus EmDebian is a binary distribution for embedded devices (whereas most of the other contenders in this space are source distributions [of course being Debian and open source the source code is still available if required].
What emdebian does In short, what EmDebian does is wrap around the regular debian package building tools to provide a more fine grained control over package selection, size, dependencies and content to enable creation of very small and efficient debian packages for use on naturally resource limited embedded targets.
二、搭建GCC编译开发环境 安装G++/GCC编译环境 sudo apt-get install gcc g++ make gdb 可以使用man命令查看GCC和G++的帮助信息。 还可以通过 gcc –v/–version命令查看其版本信息,通过这些信息我们能够了解到编译器的一些情况。
安装相应的开发帮助文件 使用以下命令安装开发所需的帮助文档,这些文档包括了linux API函数的说明和例子等等。 sudo apt-get install manpages-dev manpages-posix-dev libstdc++6-4.4-doc 安装时,系统会将关联的软件包一并安装。
安装结束后,即可测试一下相关的帮助文档。 三、搭建GCC交叉编译开发环境 我们采用emdebian提供的已配置好的交叉编译器,这样做可降低初学者的入门难度。当然,传统的嵌入式开发还是建议自己编译配置交叉编译器,以此得到一个更适合自己项目的开发环境。比如:得到一个支持uclibc库的编译器;得到一个支持定点运算的编译器等等。关于如何定制一套属于自己的交叉编译器,这个问题我们将留到以后的课程中详细讲解。在此,我们可以先认为emdebian提供的交叉编译器就是我们需要的。
添加emdebian网站提供的软件包源 使用nano命令编辑系统的/etc/apt/sources.list软件源列表文件,在其中添加emdebian网站提供的软件包源地址。 sudo nano /etc/apt/sources.list
除了testing版本的软件包源外,我们还可使用stable版本的。 deb http://www.emdebian.org/debian/ stable main deb-src http://www.emdebian.org/debian/ stable main debian的程序版本管理机制将软件分为了unstable, testing, stable三个版本,其中stable为稳定的版本,但版本也较unstable和testing低一些。
更新软件源信息安装源的数字证书 使用apt-get update命令更新软件源的包描述信息,通过这些信息,我们可以知道一个软件源提供哪些版本的安装软件及源代码包。 sudo apt-get update 通过安装emdebian-archive-keyring就可以安装emdebian网站提供的软件源的数字证书,数字证书是一种安全认证机制,有了数字证书就可以避免安装到非法网站提供的软件源。 sudo apt-get install emdebian-archive-keyring
安装G++/GCC交叉编译开发环境 在emdebian软件源中,将一个类型的交叉编译开发环境分为了13个软件包。这些软件包括了:binutils, cpp, g++, gcc, gdb, libc库, libstdc++库, linux头文件等等。可以通过apt-get install命令进行安装,以下我们已arm-linux-gnu为例,安装这一套交叉编译器的软件包: 支持OABI接口的编译器安装包: binutils-arm-linux-gnu (版本 2.18.1~cvs20080103-7) cpp-4.3-arm-linux-gnu (版本 4.3.2-1.1) g++-4.3-arm-linux-gnu (版本 4.3.2-1.1) gcc-4.3-arm-linux-gnu (版本 4.3.2-1.1) gcc-4.3-arm-linux-gnu-base (版本 4.3.2-1.1) libc6-arm-cross (版本 2.7-18) libc6-dev-arm-cross (版本 2.7-18) libgcc1-arm-cross (版本 1:4.3.2-1.1) libstdc++6-4.3-dev-arm-cross (版本 4.3.2-1.1) libstdc++6-4.3-pic-arm-cross (版本 4.3.2-1.1) libstdc++6-arm-cross (版本 4.3.2-1.1) linux-kernel-headers-arm-cross (版本 2.6.18-6) gdb-arm-linux-gnu (版本 6.8-3)
支持EABI接口的编译器安装包: binutils-arm-linux-gnueabi (2.18.1~cvs20080103-7) cpp-4.3-arm-linux-gnueabi (4.3.2-1.1) g++-4.3-arm-linux-gnueabi (4.3.2-1.1) gcc-4.3-arm-linux-gnueabi (4.3.2-1.1) gcc-4.3-arm-linux-gnueabi-base (4.3.2-1.1) gdb-arm-linux-gnueabi (6.8-3) libc6-armel-cross (2.7-18) libc6-dev-armel-cross (2.7-18) libgcc1-armel-cross (1:4.3.2-1.1) libstdc++6-4.3-dev-armel-cross (4.3.2-1.1) libstdc++6-armel-cross (4.3.2-1.1) gcc-4.3-base-armel-cross (4.3.2-1.1) linux-libc-dev-armel-cross (2.6.26-17)
在安装过程中,一定要注意各软件包之间的版本依赖,这些依赖实际上是编译器配置的一部分,在此emdebian已为用户搭配好的了。其中gdb-arm-linux-gnu包会与之前的gdb包有冲突。解决方法如下: 找到从emdebian下载的软件包gdb-arm-linux-gnu,并将其拷贝到一个工作目录下。 cp /var/cache/apt/archives/gdb-arm-linux-gnu_6.8-3_i386.deb . 使用dpkg -x命令解压出其中的数据内容。 dpkg -x gdb-arm-linux-gnu_6.8-3_i386.deb gdb-arm-linux-gnu_6.8-3_i386 使用dpkg -e命令解压出其中的控制信息,并保存在XXX/DEBIAN目录下。 dpkg -e gdb-arm-linux-gnu_6.8-3_i386.deb gdb-arm-linux-gnu_6.8-3_i386/DEBIAN 删除文件XXX/usr/share/man/man1/gdb.1.gz,正是这个文件与gdb软件包冲突。 rm -f gdb-arm-linux-gnu_6.8-3_i386/usr/share/man/man1/gdb.1.gz 使用dpkg-deb -b命令重新打包gdb-arm-linux-gnu,生成新的软件包。 dpkg-deb -b gdb-arm-linux-gnu_6.8-3_i386 使用 dpkg -i命令手动安装gdb-arm-linux-gnu软件包。 sudo dpkg -i gdb-arm-linux-gnu_6.8-3_i386.deb
到此,交叉编译开发环境安装完毕。 四、搭建集成交叉编译开发环境 CodeBlocks集成开发环境介绍 安装提供CodeBlocks软件包的软件源 添加CodeBlocks的软件源到/etc/apt/sources.list,此软件由网站apt.jenslody.de提供。 deb http://apt.jenslody.de/ any main deb-src http://apt.jenslody.de/ any main 添加CodeBlocks依赖的库wxwidgets的软件源到/etc/apt/sources.list,此库有网站apt.wxwidgets.org提供。 deb http://apt.wxwidgets.org/ lenny-wx main deb-src http://apt.wxwidgets.org/ lenny-wx main