2011-08-24 7 views
7

Mac OS X(10.7.1)でC++のコマンドラインフラグライブラリgoogle-gflagsをビルドします。私はビルド時に生成された共有ライブラリのインストール名前を変更しないで、その後install_name_toolを使用したいビルド時に.dylibのインストール名を変更するには

$ ./configure --prefix=output 
$ make 
$ make install 

:ビルドプロセスは、次のようなです。デフォルトでは

、生成された共有ライブラリ、libgflags.dylibinstall 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を使用せずにconfiguremakeによって生成は.dylibのインストール名前を変更することは可能ですか?

+0

あなたがしようとしていることを理解できません。なぜ単に./configure --prefix/tmp/desired/location'を実行できないのですか? – adl

+0

これは有効な質問です。ビルドの場所がアプリケーションの「インストール」場所と異なるなど、さまざまな理由で '--prefix'をその場所に設定することはできません。 'configure'を使っている間、適切なリンカーフラグを渡したいだけです。 – v8891

+0

あなたのシナリオはまだ私には分かりません。標準の './configure --prefix/somewhere && make && make install'があなたの設定にどういうことを説明できますか?ビルドの場所はなぜ重要ですか? (もちろん絶対接頭辞を使うべきです) 'libglflags'にインストールしようとしていますか? (その場合は 'libtool'を使用してアプリケーションを' libflag.la'とリンクさせ、libtoolにインストールされていないライブラリとリンクするようにしてください)。ライブラリをインストールする前に一時的な場所にインストールしますか?最終的な場所にコピーされますか? (これはDESTDIR変数の仕事です) – adl

答えて

5

一般に、g ++によるリンカー引数の前には-Wlを指定し、スペースはカンマで置き換える必要があります。あなたはリンカに「-install_name /tmp/temp.dylib」を渡したいのであれば、あなたはこれを呼び出す必要があります:

g++ -Wl,-install_name,/tmp/temp.dylib ... 
4

一つの可能​​なアプローチは、手動でconfig.statusを編集することでしょう。しかし私がそれをやろうとする前に、install_name_tool -idは私の命を救った。

関連する問題