c – 无法使用fixup_bundle()创建一个带Qt的可移植包

c – 无法使用fixup_bundle()创建一个带Qt的可移植包,第1张

概述我已经在其他帖子上搜索了这个问题,但到目前为止还没有.所以我在这里. 我想创建一个可移植的包.便携式,如“我可以在任何OS X机器上运行它,即使我没有安装我需要的库(Qt)”.不幸的是,我无法弄清楚如何使用fixup_bundle()(这似乎是它的正确工具)来实现这一目标. 这是我最小的CMake生成的C项目: main.cpp中 #include <QString>#include <iost 我已经在其他帖子上搜索了这个问题,但到目前为止还没有.所以我在这里.

我想创建一个可移植的包.便携式,如“我可以在任何OS X机器上运行它,即使我没有安装我需要的库(Qt)”.不幸的是,我无法弄清楚如何使用fixup_bundle()(这似乎是它的正确工具)来实现这一目标.

这是我最小的CMake生成的C项目:

main.cpp中

#include <QString>#include <iostream>int main(){        QString s("Hello,world!");    std::cout << s.toStdString() << std::endl;    return 0;}

的CMakeLists.txt

cmake_minimum_required(VERSION 2.8.11)project(test)# That part because I use a custom build of Qt. That's not the# relevant part (I guess?)file(GLOB QTROOTS path_to_qt/Qt-4.8.1/osx/bin/qmake)find_program(QT_QMAKE_EXECUtable nameS qmake PATHS ${QTROOTS})find_package(Qt4 COMPONENTS QtCore required)include(${QT_USE_file})add_executable(test MACOSX_BUNDLE main.cpp)target_link_librarIEs(test ${QT_liBRARIES})install(SCRIPT bundle.cmake)

bundle.cmake

INCLUDE(BundleUtilitIEs)fixup_bundle(test.app "" "")

这是生成的test.app结构

test.app - Contents    - Info.pList    - Frameworks       - QtCore.framework          - Versions             - 4                - QtCore    - MacOS       - test

所需的一切似乎都在捆绑中.一切顺利编译,运行良好,但是当我调用fixup_bundle时,这就是我得到的:

vincent@hpcd0016-lion:tmp/test_bundle/ (0) > make install[100%] Built target testInstall the project...-- Install configuration: ""-- fixup_bundle--   app='test.app'--   libs=''--   dirs=''-- fixup_bundle: preparing...-- fixup_bundle: copying...-- 1/4: *NOT* copying '/Users/vincent/tmp/test_bundle/test.app/Contents/MacOS/test'-- 2/4: copying 'path_to_qt/Qt-4.8.1/osx/lib//QtCore.framework/Versions/4/QtCore'-- fixup_bundle: fixing...-- 3/4: fixing up '/Users/vincent/tmp/test_bundle/test.app/Contents/MacOS/test'  exe_dotapp_dir/='test.app/Contents/MacOS/'  item_substring='/Users/vincent/t'  resolved_embedded_item='/Users/vincent/tmp/test_bundle/test.app/Contents/MacOS/test'Install or copy the item into the bundle before calling fixup_bundle.Or maybe there's a typo or incorrect path in one of the args to fixup_bundle?CMake Error at /Applications/CMake 2.8-11.app/Contents/share/cmake-2.8/Modules/BundleUtilitIEs.cmake:568 (message):  cannot fixup an item that is not in the bundle...Call Stack (most recent call first):  /Applications/CMake 2.8-11.app/Contents/share/cmake-2.8/Modules/BundleUtilitIEs.cmake:656 (fixup_bundle_item)  bundle.cmake:2 (fixup_bundle)  cmake_install.cmake:31 (INCLUDE)make: *** [install] Error 1

有依赖路径(由otool -L给出):

vincent@hpcd0016-lion:test.app/Contents/ (0) > otool -L test.app/Contents/MacOS/test         test.app/Contents/MacOS/test:        path_to_qt/Qt-4.8.1/osx/lib//QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0,current version 4.8.1)        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0,current version 56.0.0)        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,current version 169.3.0)vincent@hpcd0016-lion:tmp/test_bundle/ (0) > otool -L test.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore    test.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore:        path_to_qt/Qt-4.8.1/osx/lib//QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0,current version 4.8.1)        /usr/lib/libz.1.dylib (compatibility version 1.0.0,current version 1.2.5)        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,current version 159.1.0)        /System/library/Frameworks/applicationservices.framework/Versions/A/applicationservices (compatibility version 1.0.0,current version 41.0.0)        /System/library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0,current version 635.15.0)        /System/library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0,current version 55010.0.0)        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0,current version 52.0.0)        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0,current version 1094.0.0)        /System/library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0,current version 53.0.0)

显然,fixup_bundle没有修复捆绑包,因为二进制文件仍然将其ID设置为我的机器路径.

在这个简单的例子中,我做错了什么?

解决方法 我在CMakeLists.txt的顶部添加了这一行
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})

就是这样.

默认情况下,显然,CMAKE_INSTALL_PREFIX在我的机器上设置为/usr/local.如果将其更改为我当前的工作目录解决了问题,这意味着CMake正在尝试在/usr/local上执行某些 *** 作(不允许这样做).那么为什么错误消息没有提到这样一个正确的访问错误?

我不知道我是否没有阅读足够的文档,或者文档是否需要一些精确的…

总结

以上是内存溢出为你收集整理的c – 无法使用fixup_bundle()创建一个带Qt的可移植包全部内容,希望文章能够帮你解决c – 无法使用fixup_bundle()创建一个带Qt的可移植包所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1244540.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存