Mac OS X(10.7.1)でC++のコマンドラインフラグライブラリgoogle-gflagsをビルドします。私はビルド時に生成された共有ライブラリのインストール名前を変更しないで、その後install_name_tool
を使用したいビルド時に.dylibのインストール名を変更するには
$ ./configure --prefix=output
$ make
$ make install
:ビルドプロセスは、次のようなです。デフォルトでは
、生成された共有ライブラリ、libgflags.dylib
のinstall nameは、出力パスです:
$ otool -L ./output/libgflags.dylib
$ ./output/libgflags.dylib:
/tmp/gflags-1.5/output/lib/libgflags.0.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
ld(1)
のmanページには、ダイナミックのインストール名前を変更するために使用することができます-install_name
オプションを持っていますリンク時のライブラリ。ダミープログラムで例えば
、:
$ g++ -dynamiclib temp.cc -install_name /tmp/temp.dylib -o temp.dylib
$ otool -L temp.dylib
temp.dylib:
/tmp/temp.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
しかし、私は./configure
スクリプトで、このコマンドラインオプションを使用することができません。私はCFLAGS
変数を設定し、手動で試してみたが、それはエラーが発生:だから、
$ CFLAGS="-install_name /tmp/desired/location/libgflags.dylib" ./configure
checking for a BSD-compatible install... /opt/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/vibhav/Code/install_name_test/gflags-1.5':
configure: error: C compiler cannot create executables
を私はinstall_name_tool
を使用せずにconfigure
とmake
によって生成は.dylibのインストール名前を変更することは可能ですか?
あなたがしようとしていることを理解できません。なぜ単に./configure --prefix/tmp/desired/location'を実行できないのですか? – adl
これは有効な質問です。ビルドの場所がアプリケーションの「インストール」場所と異なるなど、さまざまな理由で '--prefix'をその場所に設定することはできません。 'configure'を使っている間、適切なリンカーフラグを渡したいだけです。 – v8891
あなたのシナリオはまだ私には分かりません。標準の './configure --prefix/somewhere && make && make install'があなたの設定にどういうことを説明できますか?ビルドの場所はなぜ重要ですか? (もちろん絶対接頭辞を使うべきです) 'libglflags'にインストールしようとしていますか? (その場合は 'libtool'を使用してアプリケーションを' libflag.la'とリンクさせ、libtoolにインストールされていないライブラリとリンクするようにしてください)。ライブラリをインストールする前に一時的な場所にインストールしますか?最終的な場所にコピーされますか? (これはDESTDIR変数の仕事です) – adl