1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ライブラリの使い方

Posted at

ライブラリを自分のプロジェクトで使う手順です。
ライブラリの作り方で作ったLibrary1を使用します。

プロジェクトを作る

新しいソリューションとライブラリを呼び出すアプリケーションのプロジェクトを作成します。
プロジェクトテンプレートはBlank Application for MT3620 RDBを選んでください。

ファイル > 新規作成 > プロジェクト
image.png

ライブラリのファイルをコピー

ライブラリのヘッダファイルとアーカイブファイルを、任意のフォルダにコピーしてください。
ここでは、ソリューションフォルダにlibフォルダを作って、そこにコピーしました。

image.png

プロジェクトからライブラリを参照

プロジェクトに、ライブラリへの参照を設定します。
これは、ヘッダファイルのフォルダ指定と、アーカイブファイル指定の2つをやる必要があります。

ヘッダファイルのフォルダ指定

プロジェクトのプロパティを開いて、Additional Include Directoriesにヘッダファイルのフォルダを追加します。

プロジェクト > プロパティ、 構成プロパティ > C/C++ > General > Additional Include Directories
image.png
image.png

絶対フォルダ名の代わりに、$(SolutionDir)マクロで指定しています。

アーカイブファイル指定

プロジェクトのプロパティを開いて、Additional Dependenciesにアーカイブファイルを追加します。

プロジェクト > プロパティ、 構成プロパティ > Linker > Input > Additional Dependencies
image.png
image.png

絶対フォルダ名の代わりに、$(SolutionDir)マクロで指定しています。

アプリケーションからライブラリを呼び出す

main.c(断片)
...
# include <Library1.h>
...
int main(int argc, char *argv[])
{
...
    // Main loop
    const struct timespec sleepTime = {1, 0};
	int val = 0;
    while (!terminationRequired) {
        Log_Debug("%d %d\n", val, pow2(val));
		val++;
        nanosleep(&sleepTime, NULL);
    }
...
}

実行結果

image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?