我正在尝试通过我创建的Makefile编译c模块但是我收到错误致命错误:asm / linkage.h:没有这样的文件或目录。下面是c程序和Makefile的代码。确切的错误是:
sudo make
gcc -I/home/pi/linux-03f35fe498e5516091e4fd66d1700e8d0b0f4915/include -c my_loader.c -o my_loader.o
In file included from /home/pi/linux-03f35fe498e5516091e4fd66d1700e8d0b0f4915/include/linux/kernel.h:6:0,
from /home/pi/linux-03f35fe498e5516091e4fd66d1700e8d0b0f4915/include/linux/list.h:8,
from /home/pi/linux-03f35fe498e5516091e4fd66d1700e8d0b0f4915/include/linux/module.h:9,
from my_loader.c:1:
/home/pi/linux-03f35fe498e5516091e4fd66d1700e8d0b0f4915/include/linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory
#include <asm/linkage.h>
^
compilation terminated.
Makefile:10: recipe for target 'my_loader.o' failed
make: *** [my_loader.o] Error 1
C模块
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/platform_device.h>
#include <sound/simple_card.h>
#include <linux/delay.h>
void device_release_callback(struct device *dev) { /* do nothing */ };
static struct asoc_simple_card_info snd_rpi_simple_card_info = {
.card = "snd_rpi_simple_card", // -> snd_soc_card.name
.name = "simple-card_codec_link", // -> snd_soc_dai_link.name
.codec = "snd-soc-dummy", // "dmic-codec", // -> snd_soc_dai_link.codec_name
.platform = "20203000.i2s",
.daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM,
.cpu_dai = {
.name = "20203000.i2s", // -> snd_soc_dai_link.cpu_dai_name
.sysclk = 0 },
.codec_dai = {
.name = "snd-soc-dummy-dai", //"dmic-codec", // -> snd_soc_dai_link.codec_dai_n$
.sysclk = 0 },
};
static struct platform_device snd_rpi_simple_card_device = {
.name = "asoc-simple-card", //module alias
.id = 0,
.num_resources = 0,
.dev = { .release = &device_release_callback,
.platform_data = &snd_rpi_simple_card_info, // *HACK ALERT*
},
};
int hello_init(void)
{
const char *dmaengine = "bcm2708-dmaengine"; //module name
int ret;
ret = request_module(dmaengine);
pr_alert("request module load '%s': %d\n",dmaengine, ret);
ret = platform_device_register(&snd_rpi_simple_card_device);
pr_alert("register platform device '%s': %d\n",snd_rpi_simple_card_device.name,$
pr_alert("Hello World :)\n");
return 0;
}
void hello_exit(void)
{// you'll have to sudo modprobe -r the card & codec drivers manually (first?)
platform_device_unregister(&snd_rpi_simple_card_device);
pr_alert("Goodbye World!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_DESCRIPTION("ASoC simple-card I2S setup");
MODULE_AUTHOR("Plugh Plover");
生成文件
SOURCES = my_loader.c
OBJECTS = $(SOURCES:%.c=%.o)
TARGET = myExecutable
$(TARGET): $(OBJECTS)
gcc $^ -o $@
%.o: %.c
gcc -I/home/pi/linux-03f35fe498e5516091e4fd66d1700e8d0b0f4915/include -$< -o $@
我在Raspbian Jessie上,uname -r
返回 4.4.38-v7 + 。 Stackoverflow上有许多类似的问题,但它们并不适用于我。