LoginSignup
3
2

More than 5 years have passed since last update.

gcc -shared するときに -c をつけてはいけない

Last updated at Posted at 2015-01-10
gcc -shared -fPIC -o libfunc.so -c func.c  -lpng

オブジェクトファイルになるが共有ライブラリにならない。実行バイナリのソースとのリンクは通るが依存ライブラリのリンクが通らなかったりわけがわからないことが起きる。

正しくは以下

gcc -shared -fPIC -o libfunc.so func.c  -lpng

共有ライブラリとして動かないのは他のオプションが原因なのかと思って3時間ぐらいハマった。

3
2
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
3
2