我在 VMWare 虚拟机中运行 Lubuntu 17.04。我正在尝试编译并安装驱动程序D-Link DUB-1312 Gigabit Ethernet Adapter
。但是,当我尝试运行时,我在下面的代码块中收到错误make
。在其他地方阅读类似问题后,我看到其他用户询问是否binutils
安装了。它安装在我的 Lubuntu 系统上。我是一个没有经验的 Linux 用户。
make -C /lib/modules/4.10.0-19-generic/build SUBDIRS=/home/magnus/Documents/DUB modules
make[1]: Entering directory '/usr/src/linux-headers-4.10.0-19-generic'
arch/x86/Makefile:140: CONFIG_X86_X32 enabled but no binutils support
./scripts/gcc-version.sh: line 25: gcc: command not found
./scripts/gcc-version.sh: line 26: gcc: command not found
make[1]: gcc: Command not found
make[1]: gcc: Command not found
make[1]: gcc: Command not found
make[1]: gcc: Command not found
make[1]: gcc: Command not found
CC [M] /home/magnus/Documents/DUB/DUB-13X2.o
/bin/sh: 1: gcc: not found
scripts/Makefile.build:301: recipe for target '/home/magnus/Documents/DUB/DUB-13X2.o' failed
make[2]: *** [/home/magnus/Documents/DUB/DUB-13X2.o] Error 127
Makefile:1524: recipe for target '_module_/home/magnus/Documents/DUB' failed
make[1]: *** [_module_/home/magnus/Documents/DUB] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-19-generic'
Makefile:30: recipe for target 'default' failed
make: *** [default] Error 2
有人能给点建议吗?我被这个问题困了太久了。
编辑:gcc
按照 Arun 的建议进行安装后,我取得了一些进展。现在我收到一个新错误:
make -C /lib/modules/4.10.0-19-generic/build SUBDIRS=/home/magnus/Documents/DUB modules
make[1]: Entering directory '/usr/src/linux-headers-4.10.0-19-generic'
CC [M] /home/magnus/Documents/DUB/DUB-13X2.o
/home/magnus/Documents/DUB/DUB-13X2.c:55:6: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
" " __TIME__ " " __DATE__ "\n"
^~~~~~~~
/home/magnus/Documents/DUB/DUB-13X2.c:55:19: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
" " __TIME__ " " __DATE__ "\n"
^~~~~~~~
cc1: some warnings being treated as errors
scripts/Makefile.build:301: recipe for target '/home/magnus/Documents/DUB/DUB-13X2.o' failed
make[2]: *** [/home/magnus/Documents/DUB/DUB-13X2.o] Error 1
Makefile:1524: recipe for target '_module_/home/magnus/Documents/DUB' failed
make[1]: *** [_module_/home/magnus/Documents/DUB] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.10.0-19-generic'
Makefile:30: recipe for target 'default' failed
make: *** [default] Error 2
如果有人问,这是我的 Makefile:
CURRENT = $(shell uname -r)
#TARGET = usbnet
#OBJS = usbnet.o
TARGET = DUB-13X2
OBJS = DUB-13X2.o
MDIR = drivers/net/usb
KDIR = /lib/modules/$(CURRENT)/build
#KDIR = /root/Desktop/Android/UBIQCONN/android-3.0
SUBLEVEL= $(shell uname -r | cut -d '.' -f 3 | cut -d '.' -f 1 | cut -d '-' -f 1 | cut -d '_' -f 1)
USBNET = $(shell find $(KDIR)/include/linux/usb/* -name usbnet.h)
ifneq (,$(filter $(SUBLEVEL),14 15 16 17 18 19 20 21))
MDIR = drivers/usb/net
#USBNET = $(shell find $(KDIR)/$(MDIR)/* -name usbnet.h)
endif
#ifneq (,$(filter $(SUBLEVEL),21 22 23 24))
#USBNET = $(shell find $(KDIR)/$(MDIR)/* -name usbnet.h)
#endif
#$(if $(USBNET),,$(error $(KDIR)/$(MDIR)/usbnet.h not found. please refer to readme file for the detailed description))
EXTRA_CFLAGS = -DEXPORT_SYMTAB
PWD = $(shell pwd)
DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)
obj-m := $(TARGET).o
default:
make -C $(KDIR) SUBDIRS=$(PWD) modules
$(TARGET).o: $(OBJS)
$(LD) $(LD_RFLAG) -r -o $@ $(OBJS)
install:
su -c "cp -v $(TARGET).ko $(DEST) && /sbin/depmod -a"
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
.PHONY: modules clean
-include $(KDIR)/Rules.make
编辑 2:我按照 Arun 的建议添加了标志 -Wno-date-time。这使得驱动程序可以编译!经过一番努力,我也成功安装了驱动程序。如果你的回答是“答案”,而不是评论,Arun,我会将其标记为解决方案。