A toolchain is a set of tools that allows you to compile code. For OpenMoko, we have to differenciate the following use-cases:

+

工具链是一组用来编译代码的工具集。OpenMoko有两类不同用途的工具链:

−

* Developing a single application

+

* 开发简单的应用程序

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, 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]].

−

* System Integration and customizing a distribution

+

* 系统集成和定制发行版

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.

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.

−

=Basic toolchain usage=

+

=基本工具链的用法=

−

==Prerequisites==

+

==先决条件==

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 <tt>/usr/local/</tt> (becoming root if needed). If any of this is not the case, please call your local administrator for help.

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 <tt>/usr/local/</tt> (becoming root if needed). If any of this is not the case, please call your local administrator for help.

The prebuilt toolchain can be downloaded from [[http://downloads.openmoko.org/toolchains downloads.openmoko.org]]:

The prebuilt toolchain can be downloaded from [[http://downloads.openmoko.org/toolchains downloads.openmoko.org]]:

Line 71:

Line 71:

. /usr/local/openmoko/arm/setup-env

. /usr/local/openmoko/arm/setup-env

−

==Building a sample project==

+

==构建简单的项目==

In a choosen destination directory (in this example ~/):

In a choosen destination directory (in this example ~/):

Line 100:

Line 100:

make install

make install

−

==Packaging your application==

+

==打包编译好的应用程序==

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.

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.

简介

工具链是一组用来编译代码的工具集。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).

The prebuilt toolchain is for x86_64 or i686. If you wanted, you could build it on your own with OE:

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 ~/):

copy the downloaded sample application source:

cp -r /usr/local/openmoko/source/openmoko-sample2 ~/

Remember to set the proper environment variables (again with "sh" or "bash") for openmoko:

. /usr/local/openmoko/arm/setup-env

You need to create a build configuration for this application. This also checks if all needed libraries, tools, etc.. is available on your system. If this fails see the notes about the needed packages in the section "Prerequisites" mentioned earlier.

om-conf openmoko-sample2

Optionally now you can modify the source code in openmoko-sample2/src

To build the application from the source code you only need to use "make":

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.

打包编译好的应用程序

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:

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:

Advanced topics

Using toolchain provided libraries

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.

Installing additional libraries into the toolchain

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:

Views

Personal tools

简介

工具链是一组用来编译代码的工具集。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).

The prebuilt toolchain is for x86_64 or i686. If you wanted, you could build it on your own with OE:

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 ~/):

copy the downloaded sample application source:

cp -r /usr/local/openmoko/source/openmoko-sample2 ~/

Remember to set the proper environment variables (again with "sh" or "bash") for openmoko:

. /usr/local/openmoko/arm/setup-env

You need to create a build configuration for this application. This also checks if all needed libraries, tools, etc.. is available on your system. If this fails see the notes about the needed packages in the section "Prerequisites" mentioned earlier.

om-conf openmoko-sample2

Optionally now you can modify the source code in openmoko-sample2/src

To build the application from the source code you only need to use "make":

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.

打包编译好的应用程序

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:

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:

Advanced topics

Using toolchain provided libraries

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.

Installing additional libraries into the toolchain

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: