2

Qt でカスタム フレームワークを作成したいと考えています。フレームワーク自体を作成することはできますが、Qt を実行するとフレームワークが見つかりません。

dyld: Library not loaded: QSettingsDialog.framework/Versions/0/QSettingsDialog
  Referenced from: /Users/sky/QtProjects/build-QSettingsDialog-Desktop_Qt_5_7_0_clang_64bit-Debug/Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample
  Reason: image not found

理由は単純です。バイナリは、フレームワークを探す場所を認識していません。

バイナリで otool を使用したところ、次のようになりました。

otool -L Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample 
Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample:
    QSettingsDialog.framework/Versions/0/QSettingsDialog (compatibility version 0.1.0, current version 0.1.2)
    @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.7.0, current version 5.7.0)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.7.0, current version 5.7.0)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.7.0, current version 5.7.0)
    /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

だから、私の質問は次のとおりです(詳細については、以下のものを確認してください):qmakeにライブラリのパスを設定するように指示するにはどうすればよいですか:

@rpath/QSettingsDialog.framework/Versions/0/QSettingsDialog (compatibility version 0.1.0, current version 0.1.2)

qmakeでこれを行う方法はありますか? でこれを変更する方法は知っていますinstall_name_toolが、.pro ファイルに直接追加したいと思います。


私がこれまでにやったこと:

pro ファイルを変更してバイナリの rpath に変更し、ビルド時にライブラリが配置されているパスを含めます。

otool -l Examples/SimpleExample/SimpleExample.app/Contents/MacOS/SimpleExample 
Load command 22
          cmd LC_RPATH
      cmdsize 136
         path /Users/sky/QtProjects/build-QSettingsDialog-Desktop_Qt_5_7_0_clang_64bit-Debug/Examples/SimpleExample/../../QSettingsDialog (offset 12)
Load command 23
          cmd LC_RPATH
      cmdsize 48
         path /Users/sky/Qt/5.7/clang_64/lib (offset 12)

このようにして、.rpath を使用せずに、リリースの rpath を簡単に変更できますinstall_name_tool。ただし、これを機能させるには、最初の行を次のように変更する必要があります。

@rpath/QSettingsDialog.framework/Versions/0/QSettingsDialog (compatibility version 0.1.0, current version 0.1.2)

アプリケーションのプロファイル ファイルで、次のように指定しました。

mac {
    QMAKE_LFLAGS += -F$$OUT_PWD/../../QSettingsDialog/
    QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../QSettingsDialog\''
    LIBS += -F$$OUT_PWD/../../QSettingsDialog/ -framework QSettingsDialog
}

最後の欠けている部分は、 を追加する方法@rpath/です。ご協力いただきありがとうございます。

4

1 に答える 1

2

@peppe のコメントにあるリンクのおかげで、問題を解決できました。

追加しなければなりませんでした

QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/

ライブラリー・プロ・ファイルに。@rpath/QSettingsDialog.framework/Versions/0/QSettingsDialogこのようにして、フレームワークへの参照を作成するときにQt が自動的に使用します。

于 2016-07-10T10:50:15.487 に答える