[SOLVED] subdirs template results in executables that won't execute



  • g'day,

    i'm migrating a project over to the subdirs template, and breaking it up into a dll and an executable. i have configured the LIBS variable in the .pro files accordingly, and the project successfully builds (w00).

    however, when i try and run the project from within QtCreator, on osx i get the following:

    "Failed to start program. Path or permissions wrong?"

    and on windows i get

    "The program has unexpectedly finished." In both cases, the executable is in the same directory as the dll.

    If I execute the program from the osx finder, it says "<program name> cannot be opened because of a problem". If I click "Report ..." in the problem details it says:

    "Application Specific Information:
    dyld: launch, loading dependent libraries

    Dyld Error Message:
    Library not loaded: libJASP-Common.1.dylib
    Referenced from: /Users/USER/Documents/*/JASP-Desktop.app/Contents/MacOS/JASP-Desktop
    Reason: image not found"

    Running

    otool -L JASP-Desktop

    on the executable lists the path to the dll as simply

    libJASP-Common.1.dylib (compatibility version 1.0.0, current version 1.0.0)

    making me think that it simply needs to be in the same directory as the executable (which it is) but that doesn't seem to work. i also wondered if perhaps it needs to be in the Contents/MacOS directory of the app, but this doesn't work either.

    any assistance on this would be greatly appreciated.

    with thanks



  • i've found it is necessary to copy the .dylib files into the application package, and place them beside the executable (i did try this before i originally posted, but now it works, and i have no idea what i changed) this then allowed me to run the executable from within qtcreator.

    however, the problem persisted when i tried to run from the finder. from here i was able to change the expected path in my application with the install_name_tool , changing it from :

    libLibName.1.dylib

    to

    @executable_path/libLibName.1.dylib

    if anyone is having similar issues, you can probably read more about it in deployment docs.



  • Hi, I'm having the same problem. I'm new to Mac in general, so this whole app filesystem structure is a little confusing. I've also got a subdirs project one of the sub-projects is a library and the other is the test front end (qml and such). The library builds fine and the front end is able to see the headers so compilation works but linkage fails with the same error, "image not found".

    I've moved the dylib (binary and symlinks) into the same directory as the executable, but no such luck running. After that I ran otool -L on the executable and saw that the name it wanted was libName.1.dylib, so I removed the symlink's and even renamed the library to exactly that, just to see if it would run. Still no luck. I'm confused..

    Have you made any progress? It sounds like you had the same problem.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    While developing your application, go in the run panel. You can either add or edit the DYLD_LIBRARY_PATH environment variable and point it to the folder where you have your library built.



  • Hi there. Thanks for your help, that did the trick. For the time being it works (since it's pointing to the build directory). But I'm a little confused. Is this the recommended approach or are there more steps that should be taken in .pro files so that the executable can find the library?

    My subdirs project has the following structure.

    package/
    ---- lib/
    ---- app/

    But on Mac, the project is built with as a package like applicationName.app/Contents/Mac Os/appexecutable.

    There must be a more preferred method of finding the library when it's deployed in the real world. Right?


  • Lifetime Qt Champion

    Yes there is. Qt provides macdeployqt to help you setup your application bundle.

    You also have some informations in Qt's "Developing on Mac documentation":http://qt-project.org/doc/qt-4.8/developing-on-mac.html

    If you are interested in more details, you can look at the OS X api documentation too learn more about what goes where and how to setup the various path to your dependencies



  • Cool thanks for your help. I'll be sure to give these docs a look. In the meantime, at least I'm no longer blocked. :)


Log in to reply
 

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