How to use external lib in MACOS app



  • 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
    
    

  • Lifetime Qt Champion

    Hi,

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



  • 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) ?


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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.