RTlinux3.2+linux2.4.23编程:insmod报错Couldn‘t find the kernel version the module was compiled for Linux

最近在做实验,采用了
redhat9+RTlinux3.2+linux2.4.23的环境
redhat9原linux内核为liniux2.4.20-8。
环境搭建完毕后,自己手写一个c文件进行尝试,如下。
编写test.c文件内容

#incluede <pthread.h>

pthread_t thread;

void *start_routine(void *arg)
{
	rtl_printf("hello,world\n");
	return 0;
}

int init_module(void) {
	int ret;
	ret = pthread_create (&thread, NULL, start_routine,(void *) 0);
	if (ret == EAGAIN){
		rtl_printf("Create
		thread failed.\n");
		return -1;
	}
	return 0;
}

另外,对应的Makefile如下。

all:test.o
include rtlinux/rtl.mk
clean:
	rm -f *.o
include usr/rtlinux/Rules.make

而后进行

insmod test.o

发现报错如下:

Couldn't find the kernel version the module was compiled for Linux

经排查,只需要贼test.c中增加头文件

#include 

即可。

你可能感兴趣的:(linux,linux,rtlinux,C语言)