View source for Toolchain/zh cn
From Openmoko
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Template used on this page:
Return to Toolchain/zh cn.
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page:
Template used on this page:
Return to Toolchain/zh cn.
Languages: |
English • العربية • Български • Česky • Dansk • Deutsch • Esperanto • Eesti • Español • فارسی • Suomi • Français • עברית • Magyar • Italiano • 한국어 • Nederlands • Norsk (bokmål) • Polski • Português • Română • Русский • Svenska • Slovenčina • Українська • 中文(中国大陆) • 中文(台灣) • Euskara • Català |
工具链是一组用来编译代码的工具集。OpenMoko有两类不同用途的工具链:
For this, you should use a prebuilt toolchain from the OpenMoko project. Here you can find a recipe to get started with this toolchain leading you through a series of steps to compile a project and run it on your target device. You might have heard about OpenEmbedded, however as an application programmer, you should not be using OpenEmbedded.
For this task, you should use OpenEmbedded which builds its own cross compiler during the bootstrapping/build process. System Integration and customizing a distribution is out of scope of this page.
You should be reasonably familiar with Linux and its command line tools, have an x86-compatible computer with at least 1G of free disk space. You should have experience with compiling programs from source using your local compiler. The remainder of this document will also assume you have write access in your home directory (~) and /usr/local/ (becoming root if needed). If any of this is not the case, please call your local administrator for help.
Last but not least you should have a working setup that allows you to compile native software packages using the autotools build system (the triade of ./configure, make, make install).
A (partial) list of required packages -- please append as necessary:
sudo apt-get install gcc g++ autoconf automake binutils libtool libglib2.0-dev glib-gettextize ccache libxrender-dev
The prebuilt toolchain can be downloaded from [downloads.openmoko.org]:
mkdir ~/sources cd ~/sources
wget http://downloads.openmoko.org/toolchains/openmoko-x86_64-arm-linux-gnueabi-toolchain.tar.bz2 or wget http://downloads.openmoko.org/toolchains/openmoko-i686-arm-linux-gnueabi-toolchain.tar.bz2
Next, you want to extract it on your filesystem. This toolchain is not relocatable, it needs to be installed into /usr/local/openmoko/.
Now you have the following options:
cd / tar xjvf ~/sources/openmoko-XYZ-arm-linux-gnueabi-toolchain.tar.bz2
bunzip2 openmoko-x86_64-arm-linux-gnueabi-toolchain.tar.bz2 gzip openmoko-x86_64-arm-linux-gnueabi-toolchain.tar fakeroot alien -d openmoko-x86_64-arm-linux-gnueabi-toolchain.tar.gz
bitbake meta-toolchain-openmoko
Finally, everytime you want to use this toolchain, you need to alter some environment variables, so that your tools will be found. The toolchain provides a script to do that, so the only thing you need to do is to source it. Note that if you are not using a "sh" or "bash" shell (check with "echo $SHELL") that you need to start "sh" or "bash" first.
. /usr/local/openmoko/arm/setup-env
In a choosen destination directory (in this example ~/):
cp -r /usr/local/openmoko/source/openmoko-sample2 ~/
. /usr/local/openmoko/arm/setup-env
om-conf openmoko-sample2
cd openmoko-sample2 make
If you want to install this project on host for staging usage later, a shared library, for example, you can do the following to install it into a given configured prefix.
om-conf --prefix=/usr/local/openmoko openmoko-sample2 cd openmoko-sample2 make install
We have included a script to make an ipkg out of your application. Note that this is not needed to test your application on the Neo (for that you can just scp the resulting binary and data over), however it's very handy if you want to distribute your application to others.
om-make-ipkg openmoko-sample2
Now you got openmoko-sample2_0.1_armv4t.ipk , you can `scp' it to your Neo and install it:
scp openmoko-sample2_0.1_armv4t.ipk root@192.168.0.202: ssh root@192.168.0.202 ipkg install openmoko-sample2_0.1_armv4t.ipk
Note that while you can redistribute the generated ipkg, be aware that this is a bare-bones ipk that contains no further information, i.e. you will lack library dependencies. See below how to fix this.
You can also supply the version number, a description, and an author / contacts string in a control file:
om-make-ipkg myapp myapp_control
A template of myapp_control:
Package: $appname Version: 0.1 Description: package built by openmoko toolchain Section: openmoko/applications Priority: optional Maintainer: $USER Architecture: armv4t Homepage: http://www.openmoko.org/ Depends: Source: ${SRC}
Using the external toolchain is an easy way to build applications for your Neo. If you are familiar with this procedure, you might also want to look into
Add the necessary libraries to the _LDADD field in src/Makefile.am, for example:
openmoko_sample2_LDADD = @DEPENDENCIES_LIBS@ -lmokogsmd2
make sure to run om-conf again after this.
Sooner or later you will want to compile an application that has dependencies which can't be fulfilled by the precompiled toolchain, e.g. some obscure libraries.
In that case, feel free to request the inclusion of additional libraries into the next release of the OpenMoko toolchain. Until then, here is how you enhance your already installed toolchain. Say, we want to add the library called liburiparse:
cd ~/source wget http://downloads.sourceforge.net/uriparser/uriparser-0.6.0.tar.bz2 ./configure --host=arm-angstrom-linux-gnueabi --prefix=/usr/local/openmoko/arm make make install
That's it.
If you have written a cool application which you want to share with others, the best way to do that is to
See also Customizing your OpenMoko distribution.