【发布时间】:2015-11-11 20:33:09
【问题描述】:
假设我想在编译内核之前在arch/x86/boot/string.c 中使用printk()。我必须包含哪个头文件,以便链接器知道在哪里可以找到printk()?我尝试了#include <linux/kernel.h> 和#include <linux/printk.h>,但在make bzImage 期间总是出错,告诉我链接器找不到printk:
arch/x86/boot/compressed/string.o: In function `memcmp`:
string.c:(.text+0x19): undefined reference to `printk`
【问题讨论】:
-
很遗憾没有,我尝试包含
#include <linux/printk.h>,但仍然出现错误。 -
这与标题无关。链接有问题。先试试
make clean。 -
阅读 this discussion 类似的主题...它似乎确实指向链接问题
-
头文件与链接无关。您需要知道它在哪个库中并告诉链接器与该库链接(例如添加开关“-lSomeLibrary.a”)
标签: c linux gcc compiler-errors linux-kernel