根据答案,我需要将 -lbsd 包含到 gcc 命令中。但我不知道应该将它插入这里的哪里。
我正在使用 Ubuntu 24.04 Linux vivobook16-m1605xa-mb089 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
,.
这是我需要编译的 Makefile:
SHELL := /bin/bash
TARGET = ax_usb_nic
KDIR = /lib/modules/$(shell uname -r)/build
PWD = $(shell pwd)
CFILES = ax_main.c \
ax88179_178a.c \
ax88179a_772d.c
EXTRA_CFLAGS = -DEXPORT_SYMTAB -fno-pie
ifneq (,$(filter $(SUBLEVEL),14 15 16 17 18 19 20 21))
MDIR = kernel/drivers/usb/net
else
MDIR = kernel/drivers/net/usb
endif
$(TARGET)-objs := $(CFILES:.c=.o)
obj-m := $(TARGET).o
all:
make -C $(KDIR) M=$(PWD) modules
$(CC) ax88179_programmer.c -o ax88179_programmer
$(CC) ax88179a_programmer.c -o ax88179a_programmer
#$(CC) ax_ioctl.c -o ax_ioctl
install:
ifneq (,$(wildcard /lib/modules/$(shell uname -r)/$(MDIR)/ax88179_178a.ko))
gzip /lib/modules/$(shell uname -r)/$(MDIR)/ax88179_178a.ko
endif
make -C $(KDIR) M=$(PWD) INSTALL_MOD_DIR=$(MDIR) modules_install
depmod -A
clean:
make -C $(KDIR) M=$(PWD) clean
rm -f ax88179_programmer ax88179a_programmer ax_ioctl
这是我自己添加后收到的错误#include <bsd/string.h>
:
make -C /lib/modules/6.8.0-31-generic/build M=/home/lelechko/Downloads/dexp-zh-utc2_drajver_100507_30082022/AX88772D-AX88179A-Drive/ASIX_USB_NET_Linux_Driver_v1.0.0_b7_Source/ASIX_USB_NET_Linux_Driver_v1.0.0_Source_b7 modules
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-31-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
You are using: gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
CC [M] /home/lelechko/Downloads/dexp-zh-utc2_drajver_100507_30082022/AX88772D-AX88179A-Drive/ASIX_USB_NET_Linux_Driver_v1.0.0_b7_Source/ASIX_USB_NET_Linux_Driver_v1.0.0_Source_b7/ax_main.o
/home/lelechko/Downloads/dexp-zh-utc2_drajver_100507_30082022/AX88772D-AX88179A-Drive/ASIX_USB_NET_Linux_Driver_v1.0.0_b7_Source/ASIX_USB_NET_Linux_Driver_v1.0.0_Source_b7/ax_main.c:4:10: fatal error: bsd/string.h: No such file or directory
4 | #include <bsd/string.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [scripts/Makefile.build:243: /home/lelechko/Downloads/dexp-zh-utc2_drajver_100507_30082022/AX88772D-AX88179A-Drive/ASIX_USB_NET_Linux_Driver_v1.0.0_b7_Source/ASIX_USB_NET_Linux_Driver_v1.0.0_Source_b7/ax_main.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.8.0-31-generic/Makefile:1926: /home/lelechko/Downloads/dexp-zh-utc2_drajver_100507_30082022/AX88772D-AX88179A-Drive/ASIX_USB_NET_Linux_Driver_v1.0.0_b7_Source/ASIX_USB_NET_Linux_Driver_v1.0.0_Source_b7] Error 2
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-31-generic'
make: *** [Makefile:20: all] Error 2
我很感激你的帮助,因为我在 Makefiles 中完全是菜鸟,我只是想为我的 DEXP ZH-UTC2 usb-ethernet 适配器安装驱动程序