Archive

Posts Tagged ‘CrossCompile’

Cross Compile SDL

August 3rd, 2010 No comments

==============================
jpeg-8b

./configure –host=arm-linux –prefix=/opt/rootfs/cross/arm/usr
make
make install

==============================
libpng-1.2.44

./configure –host=arm-linux –prefix=/opt/rootfs/cross/arm/usr/
make
make install

==============================
zlib-1.2.5

export CC=arm-linux-gcc
./configure –shared –prefix=/opt/rootfs/cross/arm/usr
make
make install

==============================
e2fsprogs-1.41.12

./configure –host=arm-linux –prefix=/opt/rootfs/cross/arm/usr
make
make install

==============================
freetype-2.3.12

./configure –host=arm-linux –prefix=/opt/rootfs/cross/arm/usr
make
make install

==============================
DirectFB-1.4.3
依赖: JPEG, libpng, e2fsprogs(uuid), zlib, freetype2
make的时候如果在Makefile里面出现没有相关的头文件就进相关的Makefile修改CFLAGS增加你头文件和库文件的地址, 如果你不是Davinci平台,就进入gfxdrivers/Makefile把”DAVINCI_DIR”相关的东西都屏蔽掉。

./configure –host=arm-linux –prefix=/opt/rootfs/cross/arm/usr
make
make install

==============================
SDL-1.2.14
依赖: JPEG, libpng, e2fsprogs(uuid), zlib,
——

export NM=arm-linux-nm
export LD=arm-linux-ld
export CC=arm-linux-gcc
export CXX=arm-linux-g++
export RANLIB=arm-linux-ranlib
export AR=arm-linux-ar

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/arm/4.2.2-eabi/:/usr/local/arm/4.2.2-eabi/usr/:/opt/rootfs/cross/arm/usr/

如果找不到directfb库,修改Makefile, 在CFLAGS中增加你的相关库文件的路径

CFLAGS = -g -O2 -I/opt/rootfs/cross/arm/usr/include -L/opt/rootfs/cross/arm/usr/lib
LDFLAGS = $(CFLAGS)

./configure –enable-video-qtopia –enable-video-directfb –enable-video-opengl –disable-video-dummy –disable-video-fbcon –disable-video-dga –disable-arts-shared –disable-arts –disable-esd –disable-esd-shared –disable-alsa –disable-cdrom –disable-video-x11 –disable-nasm –disable-diskaudio –disable-mintaudio –disable-video-ps2gs –disable-atari-ldg –disable-video-photon –disable-nas –host=arm-linux –prefix=/opt/rootfs/cross/arm/libsdl

编译sdltest
cd test
修改Makefile增加一些库

CFLAGS = -g -O2 -I/opt/rootfs/cross/arm/libsdl/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -L/opt/rootfs/cross/arm/libsdl/lib -I/opt/rootfs/cross/arm/libsdl/include -I/opt/rootfs/cross/arm/usr/include -L/opt/rootfs/cross/arm/usr/lib -I/opt/rootfs/cross/arm/libsdl/include/SDL
LIBS = -L/opt/rootfs/cross/arm/libsdl/lib -lSDL -lpthread -ldirectfb -ljpeg -lpng -ldirect -lpng12 -lz -lfusion -lfreetype

*****************************************

1. 挂接命令:

mount -o nolock -t nfs 10.0.3.244:/long_nfs /tmp/
mount -o nolock 10.0.3.244:/long_nfs /tmp/

这两个都可以。
2. 可能出现的错误类型
a. 错误类型:

rpcbind: server localhost not responding, timed out
RPC: failed to contact local rpcbind server (errno 5).
lockd_up: makesock failed, error=-5
rpcbind: server localhost not responding, timed out
RPC: failed to contact local rpcbind server (errno 5).
mount: mounting 10.0.3.244:/long_nfs on /tmp/ failed: Input/output error

这个问题是因为挂接命令不对,要加上参数-o nolock就可以了

但是NFS不稳定

nfs: server 192.168.2.213 not responding, still trying
nfs: server 192.168.2.213 not responding, still trying
nfs: server 192.168.2.213 OK
nfs: server 192.168.2.213 OK
nfs: server 192.168.2.213 not responding, still trying
nfs: server 192.168.2.213 not responding, still trying
nfs: server 192.168.2.213 OK
nfs: server 192.168.2.213 OK
nfs: server 192.168.2.213 not responding, still trying
nfs: server 192.168.2.213 OK
nfs: server 192.168.2.213 OK
nfs: server 192.168.2.213 not responding, still trying
nfs: server 192.168.2.213 not responding, still trying

=============================

Categories: Embedded, Tech.Notes Tags: , ,

在ARM上移植openssl

November 21st, 2008 No comments

移植过程如下:

wget http://www.openssl.org/source/openssl-0.9.8h.tar.gz
tar zxvf openssl-0.9.8h.tar.gz
cd openssl-0.9.8h/
./Configure --prefix=/opt/rootfs/arm/openssl/ os/compiler:arm-linux-gcc

修改Makefile:
把: AR=ar $(ARFLAGS) r 改为:
AR=arm-linux-ar $(ARFLAGS) r

make
make install
border@ubuntu:/opt/rootfs/arm/openssl/bin$ file openssl
openssl: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.4.17, dynamically linked (uses shared libs), not stripped

-Bian Jiang

参考:
  1. http://newinfo.sysu.edu.cn/Snowwaft/?p=70

– EOF –

Categories: Embedded Tags: , ,

cross compile net-snmp for mips

November 17th, 2008 1 comment

I’m trying to cross-compile NetSNMP 5.4.2 for running on an embedded system (mips).

由于我使用的CPU是little endian 交叉编译工具是 mipsel-linux

但是如果你用的是Big endian,交叉编译用具就可能是 mips-linux

如果你是ARM平台的话,相应的改为 arm-linux

  1. 设置环境变量:

    TOOLCHAIN=mipsel-linux-
    CC=${TOOLCHAIN}gcc
    CPP=${TOOLCHAIN}cpp
    AR=${TOOLCHAIN}ar
    STRIP=${TOOLCHAIN}strip
    RANLIB=${TOOLCHAIN}ranlib
    LD=${TOOLCHAIN}ld
  2. 编译安装:

    ../net-snmp-5.4.2.1/configure --build=i686-linux --host=mipsel-linux --target=mipsel-linux \
    --with-transports="UDP"  --prefix=/opt/rootfs/snmp --with-endianness=little \
    --with-persistent-directory=/var/net-snmp/ --with-default-snmp-version="2" \
    --enable-mini-agent --without-kmem-usage --disable-debugging --disable-embedded-perl \
    --without-perl-modules
    
    make
    make install
    1. 如果你采用的是 Big endian, –with-endianness=little 应该改为 –with-endianness=big
    1. 如果不想对openssl 的支持,用 –without-openssl
  1. 测试:

    border@ubuntu:/opt/rootfs/snmp/sbin$ pwd
    /opt/rootfs/snmp/sbin
    border@ubuntu:/opt/rootfs/snmp/sbin$ file snmpd
    snmpd: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
    border@ubuntu:/opt/rootfs/snmp/sbin$ file snmptrapd
    snmptrapd: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
参考:
  1. http://fixunix.com/snmp/175765-multiple-warning-cross-compiling-net-snmp-mips-linux.html

–Bian Jiang

–EOF–

Categories: Embedded Tags: , ,

Cross Compile SSH Server Dropbear For ARM

August 15th, 2008 No comments

编译环境

  • ubuntu 8.04
  • gcc 4.2.3
  • arm_v5t_le-gcc 3.4.3

编译过程

编译zlib:

wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar zxvf zlib-1.2.3.tar.gz
mkdir zlib
cd zlib-1.2.3/
CC=arm_v5t_le-gcc ./configure --prefix=/home/border/work/SMG/build-tools/zlib
make
make install

编译dropbear:

wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.51.tar.gz
tar zxvf dropbear-0.51.tar.gz
mkdir dropbear-build
cd dropbear-build/
mkdir build
../dropbear-0.51/configure --prefix=/home/border/work/SMG/build-tools/dropbear-build/build/ \
    --with-zlib=/home/border/work/SMG/build-tools/zlib/ CC=arm_v5t_le-gcc --host=arm
make
make scp
sudo make install
sudo cp scp build/bin/

其中的scp需要单独编译,然后用把编译好的scp复制到build/bin目录下。

在交叉编译好的程序要使用 file 之类的工具检查一下是否为目标机器的程序:

border@b0rder:~/work/SMG/build-tools/dropbear-build$ file scp
scp: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.4.17,
dynamically linked (uses shared libs), not stripped

编译好的文件目录结构为:

border@b0rder:~/work/SMG/build-tools/dropbear-build/build$ tree
.
|-- bin
|   |-- dbclient
|   |-- dropbearconvert
|   |-- dropbearkey
|   `-- scp
`-- sbin
    `-- dropbear

生成server key:

cd /etc
mkdir dropbear
cd dropbear
dropbearkey -t rsa -f dropbear_rsa_host_key
dropbearkey -t dss -f dropbear_dss_host_key

启动脚本

把build目录拷贝到ARM机器上, 在启动脚步/etc/init.d/rcS中增加:

dropbear

– EOF –

Categories: Embedded Tags: , , ,

GNU Configure 中的 build target和host 的区别

August 2nd, 2008 No comments

这几天在做交叉编译的时候,对configure的build, target和host 一直搞不明白,搜了些资料记录一下:

一、 http://en.wikipedia.org/wiki/Cross_compile

The GNU autotools packages (i.e. autoconf, automake, and libtool) use the notion of a build platform, a host platform, and a target platform.

The build platform is where the code is actually compiled.

The host platform is where the compiled code will execute.

The target platform usually only applies to compilers. It represents what type of object code the package itself will produce (such as cross-compiling a cross-compiler); otherwise the target platform setting is irrelevant. For example, consider cross-compiling a video game that will run on a Dreamcast. The machine where the game is compiled is the build platform while the Dreamcast is the host platform.

二、 http://www.airs.com/ian/configure/configure_5.html#SEC30

When building cross compilation tools, there are two different systems involved: the system on which the tools will run, and the system for which the tools generate code.

The system on which the tools will run is called the host system.

The system for which the tools generate code is called the target system.

For example, suppose you have a compiler which runs on a GNU/Linux system and generates ELF programs for a MIPS embedded system. In this case the GNU/Linux system is the host, and the MIPS ELF system is the target. Such a compiler could be called a GNU/Linux cross MIPS ELF compiler, or, equivalently, a ‘i386-linux-gnu’ cross ‘mips-elf’ compiler.

简单说明一下:

  1. build 就是你现在使用的机器。
  2. host 就是你编译好的程序能够运行的平台。
  3. target 编译程序能够处理的平台。一般都用在构建编译本身的时候(gcc), 才用target, 也就是说平时我们所说的交叉编译用不到target.

Target usually have a meaning for developemt tool only.

比如: 在386的平台上编译可以运行在arm板的程序 ./configure –build=i386-linux,–host=arm-linux就可以了.

因为一般我们都是编译程序而不是编译工具.

如果我们编译工具,比如gcc,这个target就有用了.如果我们需要在一个我们的机器上为arm开发板编译一个可以处理 mips程序的gcc,那么target就是mips了.

比如:

1. ./configure --build=mipsel-linux --host=mipsel-linux
--target=mipsel-linux' will build native mipsel-linux binutils on
mipsel-linux.

2. ./configure --build=i386-linux --host=mipsel-linux
--target=mipsel-linux' will cross-build native mipsel-linux binutils on
i386-linux.

3. ./configure --build=i386-linux --host=i386-linux
--target=mipsel-linux' will build mipsel-linux cross-binutils on
i386-linux.

4. ./configure --build=mipsel-linux --host=i386-linux
--target=mipsel-linux' will cross-build mipsel-linux cross-binutils for
i386-linux on mipsel-linux.

As you see, only if $build != $host a cross-compilation is performed.
参考:
  1. http://en.wikipedia.org/wiki/Cross_compile
  2. http://www.airs.com/ian/configure/configure_5.html#SEC30
  3. http://oss.lzu.edu.cn/blog/blog.php?/do_showone/tid_116.html

– EOF –

Categories: Embedded Tags: ,