Compile driver trên linux

Khi compile driver trên linux mình gặp lỗi này dù đã trỏ đến /lib/module và tải đầy đủ tool build essential
fatal error: sys/types.h: No such file or directory #include <sys/types.h>.

Đây là Makefile:

KDIR  := /lib/modules/$(shell uname -r)/build
PWD   := $(shell pwd)
default:
	@echo "$(CC)"
	$(MAKE) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C $(KDIR) M=$(PWD) modules
clean:
	@rm -Rf *.o *.ko *.mod.c modules.order Module.symvers```

Thử lệnh này xem có thấy không?

echo "#include <sys/types.h>" | gcc -E -x c - | grep types
2 Likes

file types.h thì vẫn còn anh à. Nhưng em nghĩ có lẽ đường dẫn nó bị mất không biết có đúng không. Em echo theo anh nó ra thế này:

# 1 "/usr/include/x86_64-linux-gnu/sys/types.h" 1 3 4
# 25 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 26 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4
# 121 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 1 3 4
# 122 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4
# 30 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 60 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 98 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 132 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 133 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 146 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 147 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 194 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 216 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 217 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 220 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 223 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 270 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 1 3 4
# 21 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 2 3 4
# 60 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 90 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 124 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 211 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 271 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?