カーネルバイナリとカーネルモジュールのビルドソースはどこにありますか?

カーネルバイナリとカーネルモジュールのビルドソースはどこにありますか?

Linuxでカーネルモジュール開発環境を設定しようとしています。ホームフォルダにカーネルを構築し、適切なインクルードのためにソースとバイナリを正しい場所に配置したいと思います。

カーネルモジュールのビルドの例は次のとおりです。

#include <linux/init.h>
#include <linux/module.h>

リンカがこれらのヘッダを探す絶対パスは何ですか?

ベストアンサー1

これが私が通常問題を扱う方法です。私はFedora 19を使用していますが、locateサービスを提供するすべてのディストリビューションで動作します。

$ locate "linux/init.h" | grep include
/usr/src/kernels/3.13.6-100.fc19.x86_64.debug/include/linux/init.h
/usr/src/kernels/3.13.7-100.fc19.x86_64.debug/include/linux/init.h
/usr/src/kernels/3.13.9-100.fc19.x86_64/include/linux/init.h
/usr/src/kernels/3.13.9-100.fc19.x86_64.debug/include/linux/init.h

パスはさまざまですが、キーは含まれlocateているエントリ( "linux / init.h")を見つけて、その結果をキーワードでフィルタリングすることですinclude

RPM(Redhat)またはAPT(Debian / Ubuntu)を使用してこれらの場所を検索するディストリビューション方法もあります。

湾岸協力協議会

ただし、C/C++ ファイルのパスは相対的であることに注意してください。

#include <linux/init.h>

これにより、コンパイラを呼び出すときにgcc使用したいインクルードファイルの場所を上書きできます。これはスイッチを介して制御されます-I <dir>

man gccからの抜粋

   -I dir
        Add the directory dir to the list of directories to be searched for 
        header files.  Directories named by -I are searched before the 
        standard system include directories.  If the directory dir is a
        standard system include directory, the option is ignored to ensure 
        that the default search order for system directories and the special 
        treatment of system headers are not defeated .  If dir
        begins with "=", then the "=" will be replaced by the sysroot 
        prefix; see --sysroot and -isysroot.

外部モジュール

独自のカーネルモジュール開発をLinuxカーネルに付属の「ビルド環境」に統合する方法を説明する記事があります。記事のタイトルは次のとおりです。ドライバ移植:外部モジュールのコンパイル。この記事では、カーネルmakefileの構成も紹介します。file.txtの生成

カーネル初心者のための次の記事もあります。カーネルヘッダファイルkernelnewbies.orgのウェブサイトで検索しました。

メモ:カーネルは、カーネルに付属のドキュメントの一部として、ここで説明されているKBuildシステムを使用します。

引用する

おすすめ記事