无法使用fixup_bundle()与Qt创建可移植的捆绑包 [英] Can't use fixup_bundle() to create a portable bundle with Qt

查看:84
本文介绍了无法使用fixup_bundle()与Qt创建可移植的捆绑包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在其他帖子中搜索了此问题,但到目前为止没有任何内容.所以我在这里.

I already searched this issue on other posts, but nothing so far. So here I am.

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

I'd like to create a bundle that is portable. Portable as in "I can run it on any OS X machine, even if my required libs (Qt) are not installed". Unfortunately, I can't figure out how to use fixup_bundle() (which seems the right tool for it) to achieve this goal.

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

Here is my minimal CMake generated C++ project :

main.cpp

#include <QString>
#include <iostream>

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

CMakeLists.txt

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

bundle.cmake

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

这是生成的test.app结构

Here's the resulting test.app structure

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

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

Everything that is needed seems to be in the bundle. Everything compiles smoothly, runs well, but when I invoke fixup_bundle, that's what I get :

vincent@hpcd0016-lion:tmp/test_bundle/ (0) > make install

[100%] Built target test
Install 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提供):

There's the dependencies path (given by 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仍设置为我的机器的路径.

Obviously, fixup_bundle did not fix up the bundle for the binaries still have their ids set to my machine's paths.

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

What am I doing wrong on this simple example?

推荐答案

我在CMakeLists.txt顶部添加了这一行

I added this line at the top of my CMakeLists.txt

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})

就是这样.

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

By default, apparently, CMAKE_INSTALL_PREFIX is set to /usr/local on my machine. If changing it to my current working directory solved the issue, that means CMake was trying to perform some operations on /usr/local (which it is not allowed to do). So why the error message does not mention such a right access error?

我不知道我是否没有阅读足够的文档,或者文档是否需要一定的精度...

I don't know if I haven't read enough documentation, or if the documentation needs some precisions...

这篇关于无法使用fixup_bundle()与Qt创建可移植的捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆