Congratulations to our 2022 Qt Champions!

Import dynamic library - Failed ?

  • Hello,

    I'm still new in Qt and I'm trying to import a library that I created in a new project.

    I followed this topic : Here but it doesn't seem to work.

    When I add the library to my project, I used right click --> add library --> external and I select this previous dylib generated.

    But if I'm trying to add the include on main.cpp of my project, I can't find headers of my lib.

    PS : Sorry for examples but I can't posted the code... don't know why.

    Thanks for help,

    Kind Regards.

  • Lifetime Qt Champion

    Its not really clear what is the issue. :)

    If your lib is located in another folder and the .h files is also there, you might need
    to add the sub folder to the .pro file for it to really find it.

  • @mrjj Yes I know that it's pretty hard to understand my problem without an explanation of what I do.

    I try to create a dynamic library of a project, for that, I followed the tutorial that I said on the first post. (Changing the template + adding some stuff on my header). When I build this project, I have .dylib which are created in the build folder of the library.

    After that, I need to add this library to my current project. For that, I add this to my pro files :

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-TestLib-Desktop_Qt_5_5_1_clang_64bit-Debug/release/ -lTestLib
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-TestLib-Desktop_Qt_5_5_1_clang_64bit-Debug/debug/ -lTestLib
    else:unix: LIBS += -L$$PWD/../build-TestLib-Desktop_Qt_5_5_1_clang_64bit-Debug/ -lTestLib.1.0.0
    INCLUDEPATH += $$PWD/../build-TestLib-Desktop_Qt_5_5_1_clang_64bit-Debug
    DEPENDPATH += $$PWD/../build-TestLib-Desktop_Qt_5_5_1_clang_64bit-Debug

    After that, I'm supposed to be able to import a class of my lib in the main of the current project, but I can't. (Just like the tutorial referred on first post).

    I will see what you sent.

  • Lifetime Qt Champion

    @Lordful said:


    does this folder contain the .h file?

    It seems pretty ok.

  • @mrjj Hum of course, this folder doesn't contain the header of my file.

Log in to reply