1. 在使用openwrt编译工具链编译测试程序。
(/opt/toolchain_mspdc2k/bin/arm-openwrt-linux-gcc main.c -o test)
警告信息:
arm-openwrt-linux-gcc: warning: environment variable "STAGING_DIR" not defined
arm-openwrt-linux-gcc: warning: environment variable "STAGING_DIR" not defined
arm-openwrt-linux-gcc: warning: environment variable "STAGING_DIR" not defined
/opt/toolchain_mspdc2k/lib/gcc/arm-openwrt-linux-gnueabi/4.5.4/../../../../arm-openwrt-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/opt/toolchain_mspdc2k/lib/gcc/arm-openwrt-linux-gnueabi/4.5.4/../../../../arm-openwrt-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/opt/toolchain_mspdc2k/lib/gcc/arm-openwrt-linux-gnueabi/4.5.4/../../../../arm-openwrt-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libc_nonshared.a when searching for libc_nonshared.a
解决方法:将工具链的编译工具所在目录加入的环境变量中。
export STAGING_DIR=/opt/toolchain_mspdc2k/bin:$STAGING_DIR
/opt/toolchain_mspdc2k/bin/arm-openwrt-linux-gcc main.c -o test
2. 将输出与错误输出都重定向到一个文件。
./build.sh > a 2>&1
3. 在64-bit OS 上编译代码
error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
用一下命令安装 libmpc2:i386