1

昨日、私は MacOSX アプリケーションの展開についてたくさん読んでいましたが、まだいくつか疑問があります。過去数年間、 macdeployqtを使用して MacOSX 用の Qt4 アプリケーションをデプロイしてきました。現在、mi アプリケーションは、Qt フレームワークに属していないライブラリである Poppler を使用しています。

Homebrewを使用して poppler-qt4 をインストールしました:

brew install poppler --with-qt4 --enable-xpdf-headers

macdeployqtを使用した後、 install_name_toolを使用して絶対パスを相対パスで変更する必要があることがわかりました。一部の dylib には依存関係もあります。

MyApp.app/Contents/MacOS/MyApp:
    /usr/local/lib/libpoppler-qt4.4.dylib

/usr/local/lib/libpoppler-qt4.4.dylib:
  /usr/local/Cellar/poppler/0.20.5/lib/libpoppler.28.dylib
  /usr/local/lib/libfontconfig.1.dylib
  /usr/local/lib/QtCore.framework/Versions/4/QtCore
  /usr/local/lib/QtGui.framework/Versions/4/QtGui
  /usr/local/lib/QtXml.framework/Versions/4/QtXml

macdeployqtを使用した後、Qt フレームワークがアプリ バンドル内にコピーされていることを知りました。

自作の dylib は -headerpad_max_install_names を使用してコンパイルされてますか?

brew を使用してこれを自動的に行う方法はありますか?

install_name_toolでは何を使用すればよいですか? @executable_path または @loader_path?

編集: macdeployqt は、サード パーティの dylibs、poppler-qt4、およびそのすべての依存関係を Applicaciont.app/Frameworks フォルダーにコピーし、install_name_tool が自動的に使用されるようにデプロイするのに十分スマートであるようです。しかし、今、私はこのバグに苦しんでいます: macdeployqt がプラグインをコピーしない問題は、poppler-qt4.4 の名前の「qt」にあると思います。

4

1 に答える 1

2

すべてのパスを手動で変更できますが、エラーが発生しやすく、時間がかかり、面倒です。私がお勧めするのは、ツールを使用してそれを行うことです: cmake に含まれる cpack です。

とにかく、10.5 以降は @loader_path を使用する必要があります。Dylibを参照してください。

MacOS X の場合、次のコードはバンドルを作成し、root 権限があっても自作の dylib を適切にコピーします。ただし、自作でコンパイルされたすべてのライブラリに正しいパラメーターがあることを確認する必要があります。

通常、デプロイメントでは、ライブラリを手動でコンパイルする方が適切です。自作ライブラリ (ffmpeg) に問題がありました。しかし、QtでもBoostでもありません:-)。

if( USE_QT5 )
     qt5_use_modules( MyApp Core OpenGL Sql Multimedia Concurrent )
endif()

# Install stuff
set( plugin_dest_dir bin )
set( qtconf_dest_dir bin )
set( APPS "\${CMAKE_INSTALL_PREFIX}/bin/MyApp" )
if( APPLE )
    set( plugin_dest_dir MyApp.app/Contents/ )
    set( qtconf_dest_dir MyApp.app/Contents/Resources )
    set( APPS "\${CMAKE_INSTALL_PREFIX}/MyApp.app" )
endif( APPLE )
if( WIN32 )
    set( APPS "\${CMAKE_INSTALL_PREFIX}/bin/MyApp.exe" )
endif( WIN32 )

#--------------------------------------------------------------------------------
# Install the MyApp application, on Apple, the bundle is at the root of the
# install tree, and on other platforms it'll go into the bin directory.
install( TARGETS MyApp
    BUNDLE DESTINATION . COMPONENT Runtime
    RUNTIME DESTINATION bin COMPONENT Runtime
)

#--------------------------------------------------------------------------------
# Install needed Qt plugins by copying directories from the qt installation
# One can cull what gets copied by using 'REGEX "..." EXCLUDE'
install( DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
    "${QT_PLUGINS_DIR}/codecs"
    "${QT_PLUGINS_DIR}/phonon_backend"
    "${QT_PLUGINS_DIR}/sqldrivers"
    "${QT_PLUGINS_DIR}/accessible"
    "${QT_PLUGINS_DIR}/bearer"
    "${QT_PLUGINS_DIR}/graphicssystems"
    DESTINATION ${plugin_dest_dir}/PlugIns
    COMPONENT Runtime
    FILES_MATCHING
    PATTERN "*.dylib"
    PATTERN "*_debug.dylib" EXCLUDE
)

#--------------------------------------------------------------------------------
# install a qt.conf file
# this inserts some cmake code into the install script to write the file
install( CODE "
    file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")
    " COMPONENT Runtime
)


#--------------------------------------------------------------------------------
# Use BundleUtilities to get all other dependencies for the application to work.
# It takes a bundle or executable along with possible plugins and inspects it
# for dependencies.  If they are not system dependencies, they are copied.

# directories to look for dependencies
set( DIRS ${QT_LIBRARY_DIRS} ${MYAPP_LIBRARIES} )

# Now the work of copying dependencies into the bundle/package
# The quotes are escaped and variables to use at install time have their $ escaped
# An alternative is the do a configure_file() on a script and use install(SCRIPT  ...).
# Note that the image plugins depend on QtSvg and QtXml, and it got those copied
# over.

install( CODE "
    file(GLOB_RECURSE QTPLUGINS
      \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    set(BU_CHMOD_BUNDLE_ITEMS ON)
    include(BundleUtilities)
    fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
    " COMPONENT Runtime
)

# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X
# where CPackConfig.cmake is created by including CPack
# And then there's ways to customize this as well
set( CPACK_BINARY_DRAGNDROP ON )
include( CPack )
于 2013-01-12T10:47:00.567 に答える