compile driver on linux with make

一笑奈何 提交于 2019-12-02 09:53:08

问题


What does this error message mean? I am trying to run make. It looks like configure is missing. Configure is part of the kernel source?

make -C /lib/modules/4.2.0-19-generic/build SUBDIRS=/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-19-generic'
  CC [M]  /home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.o
/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.c:55:6: error: macro "__TIME__" might prevent reproducible builds [-Werror=date-time]
  " " __TIME__ " " __DATE__ "\n"
      ^
/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.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:264: recipe for target '/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.o' failed
make[2]: *** [/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE/ax88179_178a.o] Error 1
Makefile:1398: recipe for target '_module_/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE' failed
make[1]: *** [_module_/home/glochild/Downloads/AX88179_178A_LINUX_DRIVER_v1.10.0_SOURCE] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-19-generic'
Makefile:30: recipe for target 'default' failed
make: *** [default] Error 2

回答1:


In your Makefile add this to the CFLAGS variable

-Wno-date-time

this will disable the warning, and since warnings are treated as errors because the Makefile is passing -Werror with the CFLAGS the code can't compile.




回答2:


I understand this is due to the warning being added to later versions of GCC, which would originally compile with eg -Wall, but now no longer do so due to this additional restriction.

If you cannot fix it using the makefile mods above, I have fixed it in my own driver builds by bracketing just the offending line(s) of source with:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdate-time"
... code with __DATE_ __TIME__
#pragma GCC diagnostic pop

which turns the 'new' diagnostic off for the affected lines only.



来源:https://stackoverflow.com/questions/34798767/compile-driver-on-linux-with-make

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!