[CMake] Problems to use fixup_bundle on Mac OS X
Michael Jackson
mike.jackson at bluequartz.net
Tue May 20 13:59:30 EDT 2014
You need to set the "install_name" of the libHello.dylib so that the Bundle Script can find the library properly and fix those internal "install_name" entries.
Mike Jackson
On May 13, 2014, at 8:32 AM, Romain LEGUAY <romain.leguay at gmail.com> wrote:
> Hello everyone,
> I try to build a small Qt application (helloGUI) with a shared library (hello).
> Here is my application and library tree:
> ├── CMakeLists.txt
> ├── gui
> │ ├── CMakeLists.txt
> │ ├── bundle.cmake
> │ ├── include
> │ │ └── MainWindow.hpp
> │ ├── src
> │ │ ├── MainWindow.cpp
> │ │ └── main.cpp
> │ └── ui
> │ └── mainwindow.ui
> └── lib
> ├── CMakeLists.txt
> ├── Hello.cpp
> └── Hello.h
>
> My root CMakeLists.txt add the two sub directory: lib then gui.
> The lib CMakeLists.txt build a shared library (.dylib) and installed it inside ${CMAKE_INSTALL_PREFIX}/helloGUI.app/Contents/Libraries.
> The gui CMakeLists.txt build my Qt bundle (helloGUI.app) and installed it inside ${CMAKE_INSTALL_PREFIX} then launch the script bundle.cmake.
> bundle.cmake contains:
> include(BundleUtilities)
> fixup_bundle("${CMAKE_INSTALL_PREFIX}/helloGUI.app" "${CMAKE_INSTALL_PREFIX}/helloGUI.app/Contents/Libraries/libHello.dylib" "lib")
>
> If I don’t install it, my application works just fine. But after installation, I have some errors:
>
> Install the project...
> -- Install configuration: ""
> -- Installing: /MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib
> -- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app
> -- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents
> -- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents/Info.plist
> -- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents/MacOS
> -- Installing: /MYPATH/TestQtCMake/build/install/./helloGUI.app/Contents/MacOS/helloGUI
> -- fixup_bundle
> -- app='/MYPATH/TestQtCMake/build/install/helloGUI.app'
> -- libs='/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib'
> -- dirs='lib'
> -- fixup_bundle: preparing...
> -- fixup_bundle: copying...
> -- 1/10: *NOT* copying '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib'
> -- 2/10: *NOT* copying '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI'
> -- 3/10: copying '/Users/rleguay/Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Versions/5/QtCore'
> -- 4/10: copying '/Users/rleguay/Qt5.2.1/5.2.1/clang_64/lib/QtGui.framework/Versions/5/QtGui'
> -- 5/10: copying '/Users/rleguay/Qt5.2.1/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets'
> -- fixup_bundle: fixing...
> -- 6/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Libraries/libHello.dylib'
> -- 7/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI'
> -- 8/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore'
> -- 9/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui'
> -- 10/10: fixing up '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets'
> -- fixup_bundle: cleaning up...
> -- fixup_bundle: verifying...
> -- ===========================================================================
> -- Analyzing app='/MYPATH/TestQtCMake/build/install/helloGUI.app'
> -- bundle='/MYPATH/TestQtCMake/build/install/helloGUI.app'
> -- executable='/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI'
> -- valid='1'
> -- executable file 1: /MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/helloGUI
> -- warning: embedded item does not exist '/MYPATH/TestQtCMake/build/install/helloGUI.app/Contents/MacOS/libHello.dylib'
> --
> warning: cannot resolve item '@executable_path/../MacOS/libHello.dylib'
>
> possible problems:
> need more directories?
> need to use InstallRequiredSystemLibraries?
> run in install tree instead of build tree?
>
> warning: target '@executable_path/../MacOS/libHello.dylib' is not absolute...
> warning: target '@executable_path/../MacOS/libHello.dylib' does not exist...
> error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: @executable_path/../MacOS/libHello.dylib (No such file or directory)
> error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: @executable_path/../MacOS/libHello.dylib (No such file or directory)
> -- verified='1'
> -- info='Verified 1 executable files in '/MYPATH/TestQtCMake/build/install/helloGUI.app''
> --
> -- verified='1'
> -- info=''
> --
> -- fixup_bundle: done
>
> I see that the script search libHello.dylib inside Contents/MacOS but I don’t understand why.
> Can we set this path please?
>
> Thank you.
>
> Best regards,
> Romain
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list