作者suspect1 (嫌犯)
看板LinuxDev
标题Re: [问题] 编译hello world 模组的问题
时间Fri Jun 1 13:20:42 2007
※ 引述《suspect1 (嫌犯)》之铭言:
: ※ 引述《fish39 (犯小人了啦~~)》之铭言:
: : 应该改成 /usr/src/kernels/2.6.18-1.2798.fc6-i686/include/ 才是
: : 不晓得你後面为什麽多加了hello ??
: : 看你的错误讯息
: : 应该是你的include的路径错了,所以才找不到他要的h file
: 我後来把我的hello.c放在/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux下
: 然後再gcc -I/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux -c hello.c
: -o hello.o
: 但是仍然是hello.c:4:26: 错误:linux/module.h:没有此一档案或目录
: 可是module.h的确在那个路径下,为何编译器仍然找不到呢?
: 还有我的hello.c档放的目录有没有限制呢?请高手救救我吧~谢谢!
我改成以下之後:
gcc -I/usr/src/kernels/2.6.18-1.2798.fc6-i686/include -c hello.c -o hello.o
编译器好像可以找到module.h,但是变成其他的错误讯息了==>
usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/bitops.h:244: 错误:
expected 「=」, 「,」, 「;」, 「asm」 or 「__attribute__」 before 「int」
In file included from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/spinlock.h:56,
from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/module.h:10,
from mymodule.c:2:
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/system.h:306: 错误:
expected declaration specifiers or 「...」 before 「u8」
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/system.h:306: 错误:
expected declaration specifiers or 「...」 before 「u8」
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/system.h:307: 错误:
expected declaration specifiers or 「...」 before 「u16」
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/system.h:307: 错误:
expected declaration specifiers or 「...」 before 「u16」
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/system.h:308: 错误:
expected declaration specifiers or 「...」 before 「u32」
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/system.h:308: 错误:
expected declaration specifiers or 「...」 before 「u32」
不知道上面那些错误讯息代表什麽意思??请高手帮帮忙 orz
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.115.2