Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 核心編譯錯誤 fatal error: linux/config.h: No such file or directory 秒解

編輯:Linux 教學

編譯舊版核心模組時包含 #include ,新核心 (2.6.18+) 已移除此檔案,導致致命錯誤。解法:手動建立空的 config.h 滿足編譯依賴。

錯誤訊息


fatal error: linux/config.h: No such file or directory

解決步驟

  1. 確認核心原始碼路徑 (如 /usr/src/linux-source-2.6.38)
  2. 建立檔案:
    sudo vim /usr/src/linux-source-2.6.38/include/linux/config.h
  3. 寫入內容:

#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H
#endif
  1. 存檔離開 → 重新編譯 → 通過

背景說明

  • config.h 早期用於核心配置選項巨集定義
  • 現代核心改用 Kconfig + .config + generated/autoconf.h 機制
  • 舊驅動碼若未更新仍含此 include,補上空檔即可相容

替代方案:修正原始碼

若為自行維護模組,建議移除 #include ,改用 #include 或直接依賴 #include (需核心建構系統支援)。

一個空檔,解決跨版本編譯阻礙。

Copyright © Windows教程網 All Rights Reserved