Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Solved]dyld: Library not loaded --- for a custom widget
Forum Updated to NodeBB v4.3 + New Features

[Solved]dyld: Library not loaded --- for a custom widget

Scheduled Pinned Locked Moved Qt Creator and other tools
10 Posts 2 Posters 24.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stuartx
    wrote on last edited by
    #1

    Dear Qt experts:

    I compiled a custom widget in a .dylib (libdline45vplugin.dylib) and installed it in ~/QtSDK/Desktop/Qt/473/gcc/plugins/designer. Then I created a simple project with only one such widget in the ui. I added the following two lines in .pro to get the project compiled in addition to copy dline45v.h to the project directory:

    LIBS += -ldline45vplugin
    LIBS += -L/Users/stu/qt/CW_DL45v-build-desktop

    However I got the following runtime error:

    dyld: Library not loaded: libdline45vplugin.dylib
    Referenced from: /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t
    Reason: image not found

    Any one can tell me where should I put the dylib to get the project running? Manually or there is a tool for this purpose?

    Thanks.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You can tray to add the path to your lib to DYLD_LIBRARY_PATH, see an example in "this reply":http://developer.qt.nokia.com/forums/viewreply/19939/ of another thread.

      Additionally, what path for your lib is shown on this command:

      @
      otool -L /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stuartx
        wrote on last edited by
        #3

        Hi Volker,

        The "otool" utility shows that the libdline45vplugin.dylib does not have absolute/complete path.

        $ otool -L /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t
        /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t:
        libdline45vplugin.dylib (compatibility version 0.0.0, current version 0.0.0)

        I added the DYLD_LIBRARY_PATH in .profile. After re-refrence it, I got the env output:

        $ env |grep DY
        DYLD_LIBRARY_PATH=/Users/stu/qt/CW_DL45v-build-desktop

        However, I still get the same error. Did I miss any step?

        Thanks.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Maybe the dylib is missing some other libs, check it with otool too.

          You need not install it to plugins/designer. As long as it is not a designer plugin, it's useless in that place.

          If it is a designer plugin, then you shouldn't use that dylib for your actual program.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stuartx
            wrote on last edited by
            #5

            Hi Volker,

            a little bit history for my project.
            I want to create some custom widgets which will be used in the form layout in the Creator. I followed the online instruction, create a widget, compiled it in a dylib, and "make install" installed it in ~/QtSDK/Desktop/Qt/473/gcc/plugins/designer. However, when starting the Creator, I could not see my widget. If I manually copy the dylib to "Qt Creator.app/Contents/PlugIns/designer", the Creator crashes at startup. With the advise from other developer, I downloaded the source code of the Qt Creator, compiled it, and put it in QtSDK directory. then I can use my widget in the Creator.
            Please let me know if I was wrong in any steps in creating the custom widget.

            Now I want to test my widget to build an application, and result in this "image not found" error.

            this is the complete output of otool:

            $ otool -L /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t
            /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t:
            libdline45vplugin.dylib (compatibility version 0.0.0, current version 0.0.0)
            /Users/stu/QtSDK/Desktop/Qt/473/gcc/lib/QtGui.framework/Versions/Current/QtGui (compatibility version 4.7.0, current version 4.7.3)
            /Users/stu/QtSDK/Desktop/Qt/473/gcc/lib/QtCore.framework/Versions/Current/QtCore (compatibility version 4.7.0, current version 4.7.3)
            /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
            /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)

            Thanks.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              stuartx
              wrote on last edited by
              #6

              another question, for the app, should I compile the lib in different way from the .dylib used in designer?

              thanks.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                stuartx
                wrote on last edited by
                #7

                Now I compiled a C++ shared library libdl45v.1.0.0.dylib with the same widget source code. modified .pro as

                LIBS += -ldl45v
                LIBS += -L/Users/stu/qt/dl45v-build-desktop

                The compilation is clean. But the runtime error is still there. This time it looks for different dylib:

                dyld: Library not loaded: libdl45v.1.dylib
                Referenced from: /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t
                Reason: image not found

                my otool output:
                $ !736
                otool -L /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t
                /Users/stu/qt/t-build-desktop/t.app/Contents/MacOS/t:
                libdl45v.1.dylib (compatibility version 1.0.0, current version 1.0.0)
                /Users/stu/QtSDK/Desktop/Qt/473/gcc/lib/QtGui.framework/Versions/Current/QtGui (compatibility version 4.7.0, current version 4.7.3)
                /Users/stu/QtSDK/Desktop/Qt/473/gcc/lib/QtCore.framework/Versions/Current/QtCore (compatibility version 4.7.0, current version 4.7.3)
                /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
                /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
                /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)

                $ env |grep DY
                DYLD_LIBRARY_PATH=/Users/stu/qt/dl45v-build-desktop

                and I have these files in dl45v-build-desktop:

                Makefile
                libdl45v.1.0.dylib
                moc_dline45v.cpp
                dline45v.o
                libdl45v.1.dylib
                moc_dline45v.o
                libdl45v.1.0.0.dylib
                libdl45v.dylib

                Thanks.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  If you run this from within Qt Creator, then you must add the DYLD_LIBRARY_PATH environment variable to the execution environment (project pane/run settings). It is not pulled in from the shell!

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    stuartx
                    wrote on last edited by
                    #9

                    Hi Volker,

                    Thanks for the help. I added the path in the Projects pane. IT WORKS.

                    I will mark this thread as SOLVED shortly after the next questions cleared.

                    I want to clarify these steps:

                    1. In my case the custom widget for Designer was right and the dylib (libdline45vplugin.dylib) was correctly installed.
                    2. Why do I need to rebuild the Creator from source to use the custom widget?
                    3. I need to build a shared library for the widget to be used in app, libdl45v.1.dylib. The shared lib should be created with the same source code of the widget (exclude the widgetInterface class).

                    If I did right for the above steps, where, by default, should I put the shared lib ?

                    Thanks.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      Regarding Creator, I don't know. You'd better start a new thread in the "Tools Forum":http://developer.qt.nokia.com/forums/viewforum/13/.

                      Regarding the two libs:
                      You can link the designer plugin to the shard lib with the widgets. You must add that lib to designer/creator too. I don't know where it has to go, though.

                      Or create a static version of your widget lib and link that to the plugin. You end up with only the plugin shared lib then, no additional libs to install. That's what I do here.

                      The place for the shared lib(s) is platform dependent. Please have a look in the docs for that (deployment) resp. refer to the system specifications of your OS.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved