makefile - 使用 Makefile 编译驱动程序时出现编译错误
问题描述
当我尝试将 hello.c 编译为驱动程序组件时,出现如下错误:
root@ubuntu:/home/steven/Downloads# make
make -C /lib/modules/`uname -r`/build M=/home/steven/Downloads modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-29-generic'
CC [M] /home/steven/Downloads/hello.o
**cc1: error: code model kernel does not support PIC mode**
scripts/Makefile.build:332: recipe for target '/home/steven/Downloads/hello.o' failed
make[2]: *** [/home/steven/Downloads/hello.o] Error 1
Makefile:1552: recipe for target '_module_/home/steven/Downloads' failed
make[1]: *** [_module_/home/steven/Downloads] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-29-generic'
Makefile:13: recipe for target 'modules' failed
make: *** [modules] Error 2
我的 Makefile 如下:
ifneq ($(KERNELRELEASE),)
MODULE_NAME = hellomodule
$(MODULE_NAME)-objs := hello.o
obj-m := $(MODULE_NAME).o
else
KERNEL_DIR = /lib/modules/`uname -r`/build
MODULEDIR := $(shell pwd)
.PHONY: modules
default: modules
modules:
make -C $(KERNEL_DIR) M=$(MODULEDIR) modules
clean distclean:
rm -f *.o *.mod.c .*.*.cmd *.ko
rm -rf .tmp_versions
endif
有人可以帮我解决这个问题吗?
解决方案
推荐阅读
- android - Android Emulator 在 com.google.android.gms 中无法正常工作 ANR
- c# - 无法启动 Windows 服务,错误 1064
- r - 我需要R中的这种菱形图案
- sql-server - T-SQL Basic 自定义错误在存储过程中被忽略
- ruby-on-rails - 在 Rails 上实现 JWT
- javascript - 视图不显示图像
- air - ACTIVATE/DEACTIVATE 事件不适用于使用 Starling 框架的移动游戏应用
- c++ - 如何判断是否使用
或者 ? - html - 使用 Axios 和 VueJS 更新数据库中的数据
- python - 一个系列的 Groupby 和 max