【发布时间】:2019-01-08 14:49:42
【问题描述】:
我的 Makefile 是
obj-m := hello.o
PWD := $(shell pwd)
KERNELDIR := /lib/modules/4.4.0-130-generic/build#$(shell uname -r)/build/
default:
make -C $(KERNELDIR) M=$(PWD) #ARCH=$(ARCH) CROSS_COMPILE=$(COMPILER) modules
clean:
make -C $(KERNELDIR) M=$(PWD) #ARCH=$(ARCH) clean
我想用交叉编译器来编译它。我正在使用
编译它 make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
它抛出错误:
satya@satya-dev:~/Test/kernal$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
make -C /lib/modules/4.4.0-130-generic/build M=/home/satya/Test/kernal #ARCH=arm CROSS_COMPILE= modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-130-generic'
Makefile:704: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
make[1]: arm-none-linux-gnueabi-gcc: Command not found
LD /home/satya/Test/kernal/built-in.o
/bin/sh: arm-none-linux-gnueabi-ar: command not found
scripts/Makefile.build:418: recipe for target '/home/satya/Test/kernal/built-in.o' failed
make[2]: *** [/home/satya/Test/kernal/built-in.o] Error 127
Makefile:1437: recipe for target '_module_/home/satya/Test/kernal' failed
make[1]: *** [_module_/home/satya/Test/kernal] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-130-generic'
Makefile:7: recipe for target 'default' failed
make: *** [default] Error 2
satya@satya-dev:~/Test/kernal$
在论坛搜索时提到编译器是32位的,但我的编译器是64位的。
satya@satya-dev:~/Test/kernal$ uname -m
x86_64
连 gcc 都更新了。
satya@satya-dev:~/Test/kernal$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.10' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)
对编译有什么建议吗?
【问题讨论】:
-
你不会编译
Makefile。你使用它(通过make)来编译东西。还可以使用 remake 和-x来调试您的Makefile。 -
我的错误,我正在尝试使用“make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-”命令运行 make 文件
-
那在评论区
标签: c linux makefile cross-compiling