Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use external lib in MACOS app
Forum Updated to NodeBB v4.3 + New Features

How to use external lib in MACOS app

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 935 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Roy44R Offline
    Roy44R Offline
    Roy44
    wrote on last edited by
    #1

    Hi,
    I'm working on cross platform application.
    So I develop with QT.
    I am a newbie on MACOS.
    Qt creator makes an .app application, so I call qtmacdeply in my post compilation script.
    I use externals dylib I put in app via my script. But if I launch my application (without QtCreator)
    it crash because it can't find image of my external dylib.
    I tried to use install_name_tool command (seen in some forums) but it change nothing.
    How can I fix this?
    Thanks (sorry for my english)
    That's my post compile script :

    projectPath=$PWD
    outputDir=$PWD/build/$1
    applicationLibPath=$PWD/build/$1/MediaCad.app/Contents/Frameworks
    applicationPath=$PWD/build/$1/MediaCad.app/Contents/MacOS
    teighaModulePath=$PWD/tx/macx
    teighaDylibDir=$PWD/bin/macx
    occDylib=$PWD/bin/macx/OCC
    
    #copie des modules tx
    cd $projectPath
    echo copy teigha tx
    cp $teighaModulePath/*.tx $applicationPath
    
    #copie des modules txv
    echo copy teigha txv
    cp $teighaModulePath/*.txv $applicationPath
    
    #copie des modules mrx compilés
    echo copy compiled mrx
    cp $outputDir/*.mrx $applicationPath
    
    #copie des modules txv compilés
    echo copy compiled txv
    cp $outputDir/*.txv $applicationPath
    
    #copie des modules tx compilés
    echo copy compiled tx
    cp $outputDir/*.tx $applicationPath
    
    echo copy extern files
    cp -R $projectPath/ExternFiles/* $applicationPath
    
    echo macdeploy
    macdeployqt $outputDir/MediaCad.app
    
    
    echo copy info.pList
    cp $projectPath/Mediacad/Info.plist $outputDir/MediaCad.app/Contents
    
    echo relink dylib
    cd $applicationLibPath
    compiledFileList=$(ls *.dylib)
    
    echo copy teigha dylib
    cp $teighaDylibDir/*.dylib $applicationLibPath
    
    #relink dylib générés
    for dylibFile in $compiledFileList
    do
        for teighaLib in $teighaDylibFileList
        do
            install_name_tool -id $teighaLib $applicationLibPath/$teighaLib
            install_name_tool -change $teighaLib @executable_path/../Frameworks/$teighaLib $dylibFile
        done
    done
    
    cd $applicationLibPath
    dylibFileList=$(ls *.dylib)
    
    cd $applicationPath
    moduleFileList=$(ls *.tx *.txv *.mrx)
    
    #relink des modules tx mrx txv
    for dylibFile in $dylibFileList
    do
        for module in $moduleFileList
        do
            install_name_tool -change $dylibFile @executable_path/../Frameworks/$dylibFile $module
        done
    done
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should also change the dependencies id to something like @rpath/MyCustomLib.dylib

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Roy44R Offline
        Roy44R Offline
        Roy44
        wrote on last edited by
        #3

        qtMacdeploy do this for my own compiled libray.
        I try to do this for external library:

        • copy external library into myApp/Contents/Frameworks
        • do install_name_tool -id extenallib.dylib @rpath/externallib.dylib
          But I have an error : can't open file @rpath/externallib.dylib (no such file or directory)
          It depends on current directory (pwd) ?
        1 Reply Last reply
        0
        • Roy44R Offline
          Roy44R Offline
          Roy44
          wrote on last edited by
          #4

          I understand :
          It's not install_name_tool -id extenallib.dylib @rpath/externallib.dylib
          but install_name_tool -id @rpath/externallib.dylib extenallib.dylib

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved