Re: [問題] 編譯hello world 模組的問題

看板LinuxDev作者 (嫌犯)時間18年前 (2007/06/01 13:20), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/6 (看更多)
※ 引述《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
文章代碼(AID): #16NwohyO (LinuxDev)
文章代碼(AID): #16NwohyO (LinuxDev)