Adding 3rd party libraries for deployment



  • I have completed my project but it is using some 3rd party library like opencv. I have configured this library in my local but have to now deploy my project.

    On running otool -L MyApplication.app/Contents/MacOS/MyApplication it gives me the following result :

    XMLGeneratorApp.app/Contents/MacOS/XMLGeneratorApp:
    	@rpath/libopencv_shape.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_stitching.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_objdetect.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_superres.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_videostab.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_calib3d.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_features2d.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_highgui.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_videoio.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_imgcodecs.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_video.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_photo.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_ml.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_imgproc.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_flann.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/libopencv_core.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
    	@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.10.0, current version 5.10.0)
    	@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.10.0, current version 5.10.0)
    	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.10.0, current version 5.10.0)
    	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    	@rpath/QtXml.framework/Versions/5/QtXml (compatibility version 5.10.0, current version 5.10.0)
    	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
    

    So before doing macdeployqt ./MyApplication.app what should I do to add those libraries or will it be done automatically if I run macdeployqt ?


  • Moderators

    @Arqam said in Adding 3rd party libraries for deployment:

    So before doing macdeployqt ./MyApplication.app what should I do to add those libraries or will it be done automatically if I run macdeployqt ?

    doesn't wait for the answer take longer than to check it yourself by simply calling the command?? o.O





  • @raven-worx Just running macdeployqt ./MyApplication.app will allow the dmg to run the application in my local. But when I send the application to other systems, it will not be able to even open the window.

    It should be because of the external libraries being used. Because when I sent a sample default application without any external library it worked perfectly. Can you please tell how to solve this problem


  • Moderators

    @Arqam
    OSX Deployment docs:

    To include a 3rd party library in the application bundle, copy the library into the bundle manually, after the bundle is created.



  • @raven-worx How to do that?
    I see people saying to use install_name_tool but in my case which folder should I add in what location?


  • Moderators

    @Arqam
    you may want to take a look at macdylibbundler
    I am not very experienced with MacOSX development. Maybe @SGaist can help here?


  • Lifetime Qt Champion

    What exact error do you get with OpenCV ?

    You can crank up the verbose level to get more information about what exactly is going on.



  • @SGaist I have to do something extra for including external library (opencv here) with my project before macdeployqt right?
    I want to know what I need to do to add external libraries so that the app works in deployment.



  • @raven-worx said in Adding 3rd party libraries for deployment:

    macdylibbundler

    We have to manually copy the required libraries to our .app folder right.
    Apart from copying do we need to do anything else?



  • @raven-worx What command should I use to get all the dependecies of all the external libraries for macdylibbundler. As the read me didn't tell what to use.


  • Moderators

    @Arqam said in Adding 3rd party libraries for deployment:

    As the read me didn't tell what to use.

    Really? Not even on the very bottom of the page?!

    % dylibbundler -od -b -x ./HelloWorld.app/Contents/MacOS/helloworld
    -d ./HelloWorld.app/Contents/libs-ppc/ -p @executable_path/../libs-ppc/

    % dylibbundler -od -b -x ./HelloWorld.app/Contents/MacOS/helloworld
    -d ./HelloWorld.app/Contents/libs-intel/ -p @executable_path/../libs-intel/


  • Lifetime Qt Champion

    If your dependencies are built/installed properly, there's nothing special to do because macdeployqt should be able to locate the files based on the information within your application binary since it uses macOS tools to do its magic.



  • @SGaist But after macdeployqt we have to copy the 3rd party library to our Content/Frameworks folder right?



  • @SGaist I tried running in a different system, there when I saw the QT frameworks were proper inside the Content/Framework folder but the opencv libraries that I copied in the Framework folder were not proper. And the dmg app was not running.
    What should I do apart from copying the library in the Framework folder?


  • Lifetime Qt Champion

    Did you take a look at the macOS deployment guide ?



  • @SGaist said in Adding 3rd party libraries for deployment:

    macOS deployment guide

    Yeah I did look into that. My project which is not using any external library works fine, but this one which is using openCV is not working. I have uploaded the build directory folder, can you please have a look : https://github.com/torrtuga/QTBuildApp


  • Lifetime Qt Champion

    How did you install OpenCV in the first place ?


  • Lifetime Qt Champion

    By the way, you copied the symbolic link in your bundle not the actual libraries.



  • @SGaist Hi, thanks a lot for the reply.

    I followed the instructions here to configure openCV to my QT project : https://www.learnopencv.com/configuring-qt-for-opencv-on-osx/

    I had openCV in my system from earlier only.


  • Lifetime Qt Champion

    How did the OpenCV links get into the application bundle ?


Log in to reply
 

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