[Solved] Qt on Mac: set the path to find out *.dylib, when run under debug mode.



  • I have a test project at:
    @
    $${some_path}/
    @
    it depend upon a dylib at:
    @
    $${some_path}/lib/b.dylib
    @
    and it generated at:
    @
    $${some_path}/bin/test.app
    @

    when I cd to
    @
    $${some_path}/bin/test.app/Contents/MacOS
    @
    and run otool:
    @
    otool -L test
    @
    It ask for
    @
    ./lib/b.dylib (compatibility version 52.0.0, current version 52.122.0)
    @

    so, I must copy
    @
    $${some_path}/lib/b.dylib
    @
    to
    @
    $${some_path}/bin/test.app/Contents/MacOS/b.dylib
    @

    My problem is: How can do? If I don't want to copy the *.dylib, and also to fix the test.app with
    @
    install_name_tool
    @
    Is any way find upon b.dylib, when run debug mode in QtCreator?



  • Some times, we have project "test.app" depend upon to "b.dylib".
    But after rebuild "b.dylib", we forget to copy "b.dylib" to "test.app/Contents/MacOS/"

    In msvc2008, we can set the "porject dependencies"
    So, when we try to build porject "a", and the IDE check project a is depend upon project "b", and find some source code of project "b" has been edited,
    in this situation, the IDE build project "b" first and then build project "a".

    I think, that is a good solution.
    But in Qt:
    @
    #all.pro*
    TEMPLATE = subdirs

    SUBDIRS += test
    SUBDIRS += b
    @

    1. I don't know how to set project "test" depend upon to project "b"?
    2. When I run debug "test" project, how to set QtCreator to find out "b.dylib" in itself's output path, but don't need to copy "b.dylib" to "test.app/Contents/MacOS/"?


  • Before running your program you can set the following path variable:
    'export DYLD_LIBRARY_PATH=$${some_path}:$DYLD_LIBRARY_PATH'

    Your application will look for its dependencies in the PATHs set in this colon-separated variable.

    Check the dyld manpages for more information: 'man dyld'



  • Have a look into install_name_tool, you can change the path to the library with that one. The "Mac Deployment Guide":http://developer.qt.nokia.com/doc/qt-4.7/deployment-mac.html has some examples.



  • [quote author="szuzsq" date="1319622592"]
    My problem is: How can do? If I don't want to copy the *.dylib, and also to fix the test.app with
    @
    install_name_tool
    @
    [/quote]

    Volker, that's precisely what he is trying to avoid from what I understand! It's for debug purposes.



  • Yes, thanks all.
    I add the variable in page "Projects/Run Settings/Run Environment":
    DYLD_LIBRARY_PATH=$${some_path}:$DYLD_LIBRARY_PATH



  • Well, I guess you can mark the topic as solved then :)



  • [quote author="rcari" date="1320134557"]Well, I guess you can mark the topic as solved then :)[/quote]

    yes, yes. but how to do?



  • [quote author="szuzsq" date="1320135515"][quote author="rcari" date="1320134557"]Well, I guess you can mark the topic as solved then :)[/quote]

    yes, yes. but how to do?[/quote]

    Just go to the very first post in this thread and click the edit link on the right (just below your avatar and username). And add "[Solved]" to the topic. You can add a tag "solved" too (but others might be quicker with that :-) )


Log in to reply
 

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