Difference between revisions of "Didj Build Environment"

From eLinux.org
Jump to: navigation, search
(Prebuilt)
m (Add to Category:Compiler)
 
(7 intermediate revisions by 2 users not shown)
Line 12: Line 12:
 
Extract to C:\ (full path to bin is C:\winarm\didj\bin) It should work in the root of any partition.
 
Extract to C:\ (full path to bin is C:\winarm\didj\bin) It should work in the root of any partition.
  
'''Ubuntu 9.10'''
+
'''Ubuntu 9.10 (Karmic, but also known to work fine on 10.4-Lucid)'''
 
   
 
   
 
* [http://losinggeneration.homelinux.org/wp-upload/ubuntu-9.10-32bit-didj-arm-linux.tar.bz2 32 bit Ubuntu 9.10]
 
* [http://losinggeneration.homelinux.org/wp-upload/ubuntu-9.10-32bit-didj-arm-linux.tar.bz2 32 bit Ubuntu 9.10]
Line 20: Line 20:
 
Extract to /usr/local
 
Extract to /usr/local
  
''' Debian Lenny 64-bit'''
+
''' Debian Lenny '''
  
 
* [http://losinggeneration.homelinux.org/wp-upload/didj-debian-lenny64.tar.bz2 64 bit Debian Lenny]
 
* [http://losinggeneration.homelinux.org/wp-upload/didj-debian-lenny64.tar.bz2 64 bit Debian Lenny]
Line 31: Line 31:
 
== Building ==
 
== Building ==
 
=== Prerequisites ===
 
=== Prerequisites ===
 +
* git (In deb based distros, it's in the git-core package)
 
* gmp (In deb based distros it's often called libgmp-dev or libgmp3-dev)
 
* gmp (In deb based distros it's often called libgmp-dev or libgmp3-dev)
 
* mpfr (In deb based distros it's often called libmpfr-dev)
 
* mpfr (In deb based distros it's often called libmpfr-dev)
Line 37: Line 38:
 
* Bison
 
* Bison
 
* Make
 
* Make
* Makeinfo
+
* Makeinfo (In deb based distros it's in the texinfo package)
 
* patch
 
* patch
 
* diff
 
* diff
 +
* wget
 
* And a Unix environment (Only ''really'' tested on Linux)
 
* And a Unix environment (Only ''really'' tested on Linux)
  
Line 98: Line 100:
 
=== Others ===
 
=== Others ===
 
Any others you run into please document here.
 
Any others you run into please document here.
 +
 +
=== Environment Setup ===
 +
'''You will find it useful to create a file named 'crosscompile' with the contents below (edit accordingly for your directory structure). Whenever you want to compile anything for the device, enter 'source crosscompile' first to set the environment variables.'''
 +
 +
<code>
 +
  export ARCH=arm
 +
  export CC=arm-linux-uclibcgnueabi-gcc
 +
  export CXX=arm-linux-uclibcgnueabi-gcc
 +
  export CROSS_COMPILE=arm-linux-uclibcgnueabi-
 +
  export PATH=/opt/ctng/bin:$PATH
 +
  export PROJECT_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236
 +
  export TARGET_MACH=LF_LF1000
 +
  export ROOTFS_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236/target/didj-rootfs
 +
  export RELEASE_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236/target/release
 +
  export TFTP_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236/target/tftp
 +
  export EROOTFS_PATH=[YOUR PATH TO THE SOURCE TREE]]/Didj-Linux-4222-20090422-1236/target/erootfs.stage
 +
</code>
 +
 +
[[Category:Compiler]]

Latest revision as of 00:18, 12 April 2011

Buildcross is able to build a working toolchain that supports C and C++.

Prebuilt

Since it can be a pain to build the cross compiler on Windows, I'm providing a prebuilt toolchain. 32 bit Ubuntu 9.10 does some incorrect things during GCC's build that causes the built to fail. So I've provide that one too.

Windows

Extract to C:\ (full path to bin is C:\winarm\didj\bin) It should work in the root of any partition.

Ubuntu 9.10 (Karmic, but also known to work fine on 10.4-Lucid)

Extract to /usr/local

Debian Lenny

Extract to /usr/local

Additional mirrors would be welcomed.

Building

Prerequisites

  • git (In deb based distros, it's in the git-core package)
  • gmp (In deb based distros it's often called libgmp-dev or libgmp3-dev)
  • mpfr (In deb based distros it's often called libmpfr-dev)
  • GCC & Binutils
  • Flex
  • Bison
  • Make
  • Makeinfo (In deb based distros it's in the texinfo package)
  • patch
  • diff
  • wget
  • And a Unix environment (Only really tested on Linux)

Steps

  • git clone git://github.com/losinggeneration/buildcross.git
  • cd buildcross
  • sudo mkdir /usr/local/didj
  • sudo chown [your username]:[any group] /usr/local/didj
  • MAKE="make -j3" ./buildcross.sh didj -bl
  • Replace -j3 with however many processors/cores you have +1

After that, the cross compiler should be built. You should now be able to build binaries for the Didj. I'd suggest adding /usr/local/didj/bin to your PATH. This is often in $HOME/.profile. Depending on your shell, Bash compatible shells can use:

export PATH=/usr/local/didj/bin:$PATH

Usage

The following all assumes the PATH has been correctly setup.

Simple usage

Typical usage for compiling and linking a single file:

arm-linux-uclibcgnueabi-gcc -o hello hello.c

Autotools

Typical usage for cross compiling a project that uses autotools

./configure --host=arm-linux-uclibcgnueabi
make

CMake

CMake cross compiler rules

Save this file as ~/didj/didj.cmake

# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
SET(CMAKE_C_COMPILER   /usr/local/didj/bin/arm-linux-uclibcgnueabi-gcc)
SET(CMAKE_CXX_COMPILER /usr/local/didj/bin/arm-linux-uclibcgnueabi-g++)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  /usr/local/didj /home/harley/didj/rootfs /home/harley/didj/custom/rootfs)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Then use this command to build it. It's better to build in a clean subdirectory in CMake projects.

mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=~/didj/didj ..
make

Linux Kernel

make ARCH=arm CROSS_COMPILE=arm-linux-uclibcgnueabi-

Scons

To be written.

Others

Any others you run into please document here.

Environment Setup

You will find it useful to create a file named 'crosscompile' with the contents below (edit accordingly for your directory structure). Whenever you want to compile anything for the device, enter 'source crosscompile' first to set the environment variables.

 export ARCH=arm
 export CC=arm-linux-uclibcgnueabi-gcc
 export CXX=arm-linux-uclibcgnueabi-gcc
 export CROSS_COMPILE=arm-linux-uclibcgnueabi-
 export PATH=/opt/ctng/bin:$PATH
 export PROJECT_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236
 export TARGET_MACH=LF_LF1000
 export ROOTFS_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236/target/didj-rootfs
 export RELEASE_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236/target/release
 export TFTP_PATH=[YOUR PATH TO THE SOURCE TREE]/Didj-Linux-4222-20090422-1236/target/tftp
 export EROOTFS_PATH=[YOUR PATH TO THE SOURCE TREE]]/Didj-Linux-4222-20090422-1236/target/erootfs.stage