Cross-compiling GNU libmicrohttpd for OpenWRT

韦澄邈
2023-12-01

As a small introductory task to get GNUnet to run on small devices I started to cross- compile libmicrohttpd on my desktop computer for a router running OpenWRT.

This is not intended as a from scratch documentation, I used my notebook which already had all the development tools required for GNUnet installed, so when you start from scratch there are perhaps some more requirements.

The OpenWRT documentation is quite good but here a summary what I finally did to get libmicrohttpd to compile.

The first steps is to install the OpenWRT cross-compiling toolchain on your system. Here you can stick to the OpenWRT documentation, that worked fine for me.

OpenWrt Buildroot – Installation
http://wiki.openwrt.org/doc/howto/buildroot.exigence

OpenWrt Buildroot – Usage
http://wiki.openwrt.org/doc/howto/build

Now you have the tool chain installed.

You can find information about the cross-compiling process here:
http://wiki.openwrt.org/doc/devel/crosscompile

Here some basic information about my installation:

Target plattform: Atheros AR71xx/AR7240/AR913x/AR934x
Target plattform toolchain: toolchain-mips_r2_gcc-4.5-linaro_uClibc-0.9.32
OpenWRT buildroot path: /opt/dev/openwrt/trunk

So you shoud set the following environmental variables (in a script):

export STAGING_DIR=/opt/dev/openwrt/trunk/staging_dir
export TOOLCHAIN_DIR=$STAGING_DIR/toolchain-mips_r2_gcc-4.5-linaro_uClibc-0.9.32
export PATH=$STAGING_DIR/bin:$PATH

export LDCFLAGS=$TOOLCHAIN_DIR/usr/lib/
export LD_LIBRARY_PATH=$TOOLCHAIN_DIR/usr/lib/

Checkout libmicrohttpd

svn co https://gnunet.org/svn/libmicrohttpd ./mhd-openwrt

Configure and make:

cd mhd-openwrt
./bootstrap
./configure --prefix=$TOOLCHAIN_DIR --host=mips-openwrt-linux-uclibc --disable https

For GNU make, override the CC and LD environment variables and compile with:

make CC=mips-openwrt-linux-uclibc-gcc LD=mips-openwrt-linux-uclibc-ld
 类似资料: