wiki:TipAndDoc/Linux/OpenWRT/CrossCompile

Version 1 (modified by mitty, 12 years ago) (diff)

--

buildroot

  • Ubuntu 12.04 LTS x86_64
  • mitty@precise:~$ sudo aptitude install subversion build-essential libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev xsltproc bison
  • mitty@precise:~$ mkdir openwrt
  • mitty@precise:~/openwrt/trunk$ make prereq
    Collecting package info: done
    Collecting target info: done
    Checking 'working-make'... ok.
    Checking 'case-sensitive-fs'... ok.
    Checking 'getopt'... ok.
    Checking 'fileutils'... ok.
    Checking 'working-gcc'... ok.
    Checking 'working-g++'... ok.
    Checking 'ncurses'... ok.
    Checking 'zlib'... ok.
    Checking 'gawk'... ok.
    Checking 'flex'... ok.
    Checking 'unzip'... ok.
    Checking 'bzip2'... ok.
    Checking 'patch'... ok.
    Checking 'perl'... ok.
    Checking 'python'... ok.
    Checking 'wget'... ok.
    Checking 'git'... ok.
    Checking 'gnutar'... ok.
    Checking 'svn'... ok.
    Checking 'gnu-find'... ok.
    Checking 'getopt-extended'... ok.
    Checking 'non-root'... ok.
    
  • mitty@precise:~/openwrt/trunk$ make -j 5 V=99 2>&1 | tee build.log | grep -i error
    (snip)
    
    make[2]: [package/rootfs-prepare] Error 2 (ignored)
    Compression errors: 0
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wpe72.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    Compression errors: 0
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wpe72.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    make[3]: [/home/mitty/openwrt/trunk/bin/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-Linux-x86_64.tar.bz2] Error 1 (ignored)
    make[3]: [/home/mitty/openwrt/trunk/bin/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-Linux-x86_64.tar.bz2] Error 1 (ignored)
    
  • mitty@precise:~/openwrt$ cat > test.c
    #include <stdio.h>
    
    int main(void) {
            printf("char        -> %ld\n", sizeof(char));
            printf("short       -> %ld\n", sizeof(short));
            printf("int         -> %ld\n", sizeof(int));
            printf("long        -> %ld\n", sizeof(long));
            printf("long long   -> %ld\n", sizeof(long long));
            printf("float       -> %ld\n", sizeof(float));
            printf("double      -> %ld\n", sizeof(double));
            printf("long double -> %ld\n", sizeof(long double));
    
            return 0;
    }
    
  • mitty@precise:~/openwrt$ gcc test.c -o test.x86
  • mitty@precise:~/openwrt$ ./trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc test.c -o test
    mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
    mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
    mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
    
  • mitty@precise:~/openwrt$ file test test.x86
    test:     ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, not stripped
    test.x86: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x53177842cbc614b1f4c71bae24df294892906443, not stripped
    
  • mitty@precise:~/openwrt$ ./test.x86
    char        -> 1
    short       -> 2
    int         -> 4
    long        -> 8
    long long   -> 8
    float       -> 4
    double      -> 8
    long double -> 16
    
  • mitty@precise:~/openwrt$ ./test
    bash: ./test: cannot execute binary file
    
  • mitty@starseed:~$ uname -a
    Linux starseed 3.3.6 #1 Thu May 17 02:19:20 PDT 2012 mips GNU/Linux
    
  • mitty@starseed:~$ ./test
    char        -> 1
    short       -> 2
    int         -> 4
    long        -> 4
    long long   -> 8
    float       -> 4
    double      -> 8
    long double -> 8
    

build others

zlib

openssl