1
1

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.

gccで静的リンクと動的リンクを混在させたい

Posted at

結論

下記のように書く。
g++ main.o -Wl,-Bstatic -lAAA -lBBB -Wl,Bdynamic -lXXX -lYYY

結果、次のように静的リンクと動的リンクを混在させられる

  • 静的リンク:libAAA, libBBB
  • 動的リンク:libXXX, libYYY

gcc の -Wl オプションについて

-Wlはリンカへのオプションをカンマ区切りで書くとのこと。
以下 man gcc から抜粋

-Wl,option
Pass option as an option to the linker.  If option contains commas, it is split into multiple options at the commas.  You can use this syntax to pass an argument to the option.
For example, -Wl,-Map,output.map passes -Map output.map to the linker.  When using the GNU linker, you can also get the same effect with -Wl,-Map=output.map.
1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?