Eclipse CDT 设置 for Linux kernel module开发

阅读更多
0. Create C Makefile project
1. Project property: c/c++ general -> Paths & Symbols -> Includes -> GNU C -> Add:
    /usr/src/linux-headers-3.19.0-25/arch/x86/include
    /usr/src/linux-headers-3.19.0-25/include
2. Project property: C/C++ general -> Preprocessor -> Entries -> GNU C -> CDT User Entries -> Add -> PreProcessor Macro file -> File system path:
    /usr/src/linux-headers-3.19.0-25-generic/include/generated/autoconf.h
3. Providers: uncheck "CDT Cross GCC Built-in Compiler Settings
   (This step un-include GCC builtin include paths )

4. add Makefile:
obj-m = m1.o
m1-objs = mm1.o

PWD := $(shell pwd)  
all:  
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules  
clean:  
	rm *.o *.ko *~ *.mod.c *.order *.symvers
insmod:
	sudo insmod ./m1.ko
rmmod:
	sudo rmmod m1

5. add "insmod" and "rmmod" in "Make Target" view.

Now you can modify your mm1.c, press "Ctrl+B" to build, click "insmod" and "rmod" target to test.

你可能感兴趣的:(eclipse,cdt,kernel,module,linux)