LoginSignup
1
0

More than 5 years have passed since last update.

gccメモ

Last updated at Posted at 2019-02-28

Makefileに書かれたgccのコードを調べた時のメモを残しておく。

Makefile

common

  • -fPIC Generate position-independent code if possible

ディレクトリ探索のためのオプション

リンカオプション

プリプロセッサオプション

  • -D NAME マクロを定義する(値は1)

その他

  • -std=c++11 C++11の機能を使用する
  • -fsanitize=leak メモリリークの検出
  • -fsanitize=address 不正なメモリアクセスの検出

pkg-config

  • pkg-config の手引き
  • https://ja.wikipedia.org/wiki/Pkg-config
    • 環境変数PKG_CONFIG_PATHのパスに存在する*.pcファイルに記録された情報を元に、ビルドの際に必要な文字列を返す
    • Ubuntu なら/usr/lib/pkgconfig/以下?
  • --libs output all linker flags
  • --cflags output all pre-processor and compiler flags
  • ./configure --prefix=dir してインストールした場合、PKG_CONFIG_PATHdir/lib/pkgconfig を指定する?

    ldconfig

  • sonameをファイル名とするシンボリックリンクを作成する

  • Linux共有ライブラリの簡単なまとめ

CUnit

  • コンパイル
    • gcc ./src.c ./tsrc.c -Wall -Wl,-rpath /usr/local/lib -lcunit
    • export LD_LIBRARY_PATH=/usr/local/lib gcc ./src.c ./tsrc.c -Wall -lcunit
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