0
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?

ライブラリ等をいちいちプロジェクトルートにcloneしてこないで、 PCにおいて毎度参照させたい。

0
Last updated at Posted at 2025-08-25

事前知識

/usr
ユーザが共通で使用するプログラムやリソース

/usr/include
標準ライブラリやシステムコールのヘッダファイル

#include <stdio.h>

と書くと、コンパイラは /usr/include/stdio.h を探しに行きます。

~/.local/
ユーザー固有

.h, libの設定

/usr/local (追加)
/usr/include (標準)

に置きたいが、42ではsudo無しなので、
他のプロジェクト外に置く。

 ~/.local/opt/minilibx-linux

とする。
~/.local/opt/
ユーザー固有/opt io

MLX_DIR = $(HOME)/.local/opt/minilibx-linux
INCS    = -I$(MLX_DIR)
LIBS    = -L$(MLX_DIR) -lmlx -lXext -lX11 -lm

でOK
-I = インクルードパスの追加(ヘッダ探す場所)
-L = ライブラリパスの追加(静的/動的ライブラリ探す場所)

これで提出時プロジェクト内になくても外部参照可能。

includeの違い

# include <mlx.h>必要。

"mlx.h"
→ コンパイラはまず ソースと同じディレクトリ を探し、それで見つからなければ -I で指定したディレクトリを探す。

<mlx.h>
→ ソースと同じディレクトリは見に行かず、最初からシステムの標準インクルードパスや -I で指定したディレクトリを探す。

0
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
0
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?