3

According to the answer I need to include -lbsd to the gcc command. But I have no idea where I am supposed to insert it here.

I'm using 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.

Here is Makefile I need to compile:

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

Here is the error I receive after I added the #include <bsd/string.h> myself:

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

I would appreciate your help, as I am complete noob in Makefiles, I am just trying to install driver for my DEXP ZH-UTC2 usb-ethernet adapter

0

1 Answer 1

12

It’s not clear from your question, but I’m assuming you’re trying to add bsd/string.h because your module failed to build with an error complaining about strlcpy.

Since you’re building a kernel module, C library functions (in general, not just from the C library) and header files in /usr/include aren’t relevant; the module can only use kernel functions. strlcpy used to be available in the kernel, but it was removed in 6.8. You need to change the module to use strscpy instead. You’ll find plenty of examples linked from the KSPP tracking issue.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.