December 22, 2010

Corss Compile tcpdump for linux/mips

1. download libpcap (I use version 1.1.1 at the time of post) and tcpdump (v4.1.1 as of time of post)

2. unzip both directory under the same directory, such as download/libpcap-1.1.1 and download/tcpdump-4.1.1

Build libpcap:

3. cd libpcap-1.1.1 ;

4. vi configure; search for "linux version", and remove the entire section of "case" under "linux)" until "do we have the wireless extensions". This is so that ./configure does not try to detect linux (and fail). Our linux is fine.

5. CC=/YOUR-CROSS-COMPILER-PATH/mips-openwrt-linux-gcc ./configure --host=mips-linux  --with-pcap=linux
6.  make. after make is successful, you'll have a libpcap.a

Build tcpdump:

7. cd ../tcpdump-4.1.1

8 .vi configure; earch for "linux version", and remove the entire section of "case" under "linux*)" until ";; \n *)".

9. CC=/YOUR-CROSS-COMPILER-PATH/mips-openwrt-linux-gcc ./configure --host=mips-linux  --with-pcap=linux

10. vi Makefile; search for /usr/include and remove them; the Makefile by mistake include including files in the host system. Remove them.

11. make. you can strip the final tcpdump if you like. all done.


  1. thanks for the instructions.

    modifying the 'configure' scripts can be avoided by adding 'ac_cv_linux_vers=2' to configure options.

  2. this though I don't know how to avoid:

    # /tmp/tcpdump
    /tmp/tcpdump: can't resolve symbol '__cxa_atexit'

    anyone have any ideas ?
    I'm compiling tcpdump for a Netgear router and have their crosscompiling toolkit which I am using.

    Gcc is this:
    Using built-in specs.
    Target: mips-linux-uclibc
    Configured with: /shared/myviews/toolchain/buildroot-4.4.2-1/output/toolchain/gcc-4.4.2/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=mips-linux-uclibc --enable-languages=c,c++ --with-sysroot=/opt/toolchains/uclibc-crosstools-gcc-4.4.2-1 --with-build-time-tools=/opt/toolchains/uclibc-crosstools-gcc-4.4.2-1/usr/mips-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/shared/myviews/toolchain/buildroot-4.4.2-1/output/toolchain/gmp --with-mpfr=/shared/myviews/toolchain/buildroot-4.4.2-1/output/toolchain/mpfr --disable-nls --enable-threads --disable-multilib --disable-decimal-float --with-float=soft --with-abi=32 --with-tune=mips32 --with-arch=mips32 --with-pkgversion='Buildroot 2010.02-git' --with-bugurl=
    Thread model: posix
    gcc version 4.4.2 (Buildroot 2010.02-git)

  3. Thanks! I didn't need to modify the configure script at all when using the tomato toastman 7510 git source tree and tools.