java 如何使用dylib_捆绑应用程序中的dylib和框架

您可以手动更改所有路径,但这样做容易出错,冗长而痛苦 . 我建议使用一个工具为你做:cpack包含cpack .

无论如何,你应该使用:@loader_path . 见Dylib .

对于MacOS X,以下代码创建一个包并使用root权限正确复制homebrew dylib . 但是,您必须检查使用自制软件编译的每个lib都具有正确的参数 .

通常,对于部署,最好手动编译库 . 我在使用自制库(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 )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值