我尝试使用Mono的mkbundle工具从AMD64系统(在VM中运行的Ubuntu 14.04)中为ARM(RaspberryPi)编译本机应用程序。
单声道版本是4.4.2.11(最新版本,在执行此操作时),从Mono's package repository安装,但也尝试使用4.2.3.4。
我正在跑步:
export CC="/usr/bin/arm-linux-gnueabi-gcc"
export AS="/usr/arm-linux-gnueabi/bin/as"
/usr/bin/mkbundle --static --deps --skip-scan \
-o artifacts/MyApp \
bin/Debug/MyApp.exe bin/Debug/*.dll
如果我在RaspberryPi上运行它,这可以正常工作(虽然我不需要设置CC和AS变量)。
如果我从AMD64 VM运行它,它最终会运行命令:
/usr/bin/arm-linux-gnueabi-gcc -o artifacts/MyApp -Wall \
-D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 \
temp.c \
-L/usr/lib/pkgconfig/../../lib \
-Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic \
-lm -lrt -ldl -lpthread \
temp.o
结果是:
/ usr / lib / pkgconfig /../../ lib / libmono-2.0.a:错误添加符号:文件格式无法识别 collect2:错误:ld返回1退出状态
意识到libmono-2.0.a
来自特定于体系结构的包,我从http://download.mono-project.com/repo/debian/pool/main/m/mono/下载了armel体系结构包并将其解压缩到我的主目录中(因此有一个/home/gregmac/libmono-armel/usr/lib/libmono-2.0.a
),然后尝试了:
/usr/bin/arm-linux-gnueabi-gcc -o artifacts/MyApp -Wall \
-D_REENTRANT -I/home/gregmac/libmono-armel/usr/include/mono-2.0 \
temp.c \
-L/home/gregmac/libmono-armel/usr/lib \
-Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic \
-lm -lrt -ldl -lpthread \
-v \
temp.o
我还尝试将LIBRARY_PATH和LD_LIBRARY_PATH设置为/home/gregmac/libmono-armel/usr/lib
,但始终遇到同样的问题。
完整输出(包括-v选项):
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,
obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr
/arm-linux-gnueabi/include/c++/4.7.3 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object --disable-libmudflap --dis
able-libitm --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --e
nable-multilib --disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-l
inux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1)
COLLECT_GCC_OPTIONS='-o' 'artifacts/MyApp' '-Wall' '-D' '_REENTRANT' '-I' '/home/gregmac/libmono-armel/usr/include/mono-2.0' '-L/home/gregmac/libmono-armel/usr/lib' '-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/cc1 -quiet -v -I /home/gregmac/libmono-armel/usr/include/mono-2.0 -imultilib sf -imultiarch arm-linux-gnueabi -D _REENTRANT temp.c -quiet -dumpbase temp.c -march=armv5t -mfloat-abi=soft -mtls-dialect=gnu -auxbase temp -Wall -version -fstack-protector -o /tmp/cchyLX23.s
GNU C (Ubuntu/Linaro 4.7.3-12ubuntu1) version 4.7.3 (arm-linux-gnueabi)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
#include "..." search starts here:
#include <...> search starts here:
/home/gregmac/libmono-armel/usr/include/mono-2.0
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include-fixed
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/include
/usr/include
End of search list.
GNU C (Ubuntu/Linaro 4.7.3-12ubuntu1) version 4.7.3 (arm-linux-gnueabi)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 550509f4ff92bab4626b84fc11f267f2
temp.c: In function ‘install_dll_config_files’:
temp.c:59:2: warning: pointer targets in passing argument 2 of ‘mono_register_config_for_assembly’ differ in signedness [-Wpointer-sign]
In file included from temp.c:2:0:
/home/gregmac/libmono-armel/usr/include/mono-2.0/mono/metadata/assembly.h:102:24: note: expected ‘const char *’ but argument is of type ‘const unsigned char *’
COLLECT_GCC_OPTIONS='-o' 'artifacts/MyApp' '-Wall' '-D' '_REENTRANT' '-I' '/home/gregmac/libmono-armel/usr/include/mono-2.0' '-L/home/gregmac/libmono-armel/usr/lib' '-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/as -v -I /home/gregmac/libmono-armel/usr/include/mono-2.0 -march=armv5t -mfloat-abi=soft -meabi=5 -o /tmp/ccbJ6Gk5.o /tmp/cchyLX23.s
GNU assembler version 2.24 (arm-linux-gnueabi) using BFD version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/
LIBRARY_PATH=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'artifacts/MyApp' '-Wall' '-D' '_REENTRANT' '-I' '/home/gregmac/libmono-armel/usr/include/mono-2.0' '-L/home/gregmac/libmono-armel/usr/lib' '-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/collect2 --sysroot=/ --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X --hash-style=gnu --as-needed -m armelf_linux_eabi -z relro -o artifacts/MyApp /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/crt1.o /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/crti.o /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/crtbegin.o -L/home/gregmac/libmono-armel/usr/lib -L/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc-cross/arm-linux-gnueabi/4.7 -L/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib /tmp/ccbJ6Gk5.o -Bstatic -lmono-2.0 -Bdynamic -lm -lrt -ldl -lpthread temp.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/crtend.o /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/crtn.o
/usr/lib/../lib/libmono-2.0.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
我也尝试过相同的命令,但没有--static
,并且得到了相同的错误,但关于.so
而不是.a
文件:
/ usr / lib / pkgconfig /../../ lib / libmono-2.0.so:文件无法识别:无法识别文件格式 collect2:错误:ld返回1退出状态
我错过了一些明显的东西吗?为什么gcc仍在/usr/lib/
而不是/home/gregmac/libmono-armel/usr/lib
?是否有其他环境变量我应该设置,以便原始的mkbundle
命令可以正确调用它?