Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Cannot link to my own libraries in Qt 5.2.0 OSX w/clang++
Forum Updated to NodeBB v4.3 + New Features

Cannot link to my own libraries in Qt 5.2.0 OSX w/clang++

Scheduled Pinned Locked Moved Installation and Deployment
12 Posts 2 Posters 4.1k 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.
  • M Offline
    M Offline
    marria01
    wrote on last edited by
    #1

    I've been updating some of my code run under Qt5 on OSX and have come across an issue whereby I seem unable to link to libraries that I have created. One of my build scripts works in three stages, firstly it builds a core library that contains some basic classes that aren't GUI dependant. It then builds a library containing custom widgets which relies on the first library. The final stage builds some designer plugins.

    The first stage seems to build successfully and the resulting .dylibs are installed in /usr/lib. But when the second build reaches the linking stage, clang++ says it cannot find the library.
    @ld: library not found for -labcsCore@

    The same code compiles cleanly in linux using the same version of Qt 5.2.0 although obviously using gcc instead of clang. I have the following in the second stage project file:

    @LIBS += -L/usr/lib -labcsCore@

    Any ideas?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you really sure the libraries are installed (you would need admin rights to install them) ?
      Did you check using ls ?
      Do they follow the normal naming scheme ?

      Hope these questions helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        marria01
        wrote on last edited by
        #3

        Hi,

        They're definitely in the right place. The project was pulled down from a working copy out of SVN. The only thing I can think of is that clang isn't looking in the directory that I'm telling it to.

        @ls -lh /usr/lib/libabcs*
        -rwxr-xr-x 1 root wheel 246K 26 Dec 22:25 /usr/lib/libabcsCore.1.0.0.dylib
        lrwxr-xr-x 1 root wheel 23B 26 Dec 22:25 /usr/lib/libabcsCore.1.0.dylib -> libabcsCore.1.0.0.dylib
        lrwxr-xr-x 1 root wheel 23B 26 Dec 22:25 /usr/lib/libabcsCore.1.dylib -> libabcsCore.1.0.0.dylib
        lrwxr-xr-x 1 root wheel 23B 26 Dec 22:25 /usr/lib/libabcsCore.dylib -> libabcsCore.1.0.0.dylib
        -rwxr-xr-x 1 root wheel 1.1M 12 Jul 19:53 /usr/lib/libabcsWidgets.1.0.0.dylib
        lrwxr-xr-x 1 root wheel 26B 12 Jul 19:53 /usr/lib/libabcsWidgets.1.0.dylib -> libabcsWidgets.1.0.0.dylib
        lrwxr-xr-x 1 root wheel 26B 12 Jul 19:53 /usr/lib/libabcsWidgets.1.dylib -> libabcsWidgets.1.0.0.dylib
        lrwxr-xr-x 1 root wheel 26B 12 Jul 19:53 /usr/lib/libabcsWidgets.dylib -> libabcsWidgets.1.0.0.dylib
        @

        @file /usr/lib/libabcsCore.dylib
        /usr/lib/libabcsCore.dylib: Mach-O 64-bit dynamically linked shared library x86_64@

        @otool -L /usr/lib/libabcsCore.dylib
        /usr/lib/libabcsCore.dylib:
        libabcsCore.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        /Users/andy/Qt/5.2.0/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.2.0, current version 5.2.0)
        /Users/andy/Qt/5.2.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.0)
        /Users/andy/Qt/5.2.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.2.0, current version 5.2.0)
        /Users/andy/Qt/5.2.0/clang_64/lib/QtXml.framework/Versions/5/QtXml (compatibility version 5.2.0, current version 5.2.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)@

        First phase build partial results:

        @<snip>
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -single_module -dynamiclib -compatibility_version 1.0 -current_version 1.0.0 -install_name libabcsCore.1.dylib -o libabcsCore.1.0.0.dylib abcs_debug.o abcs_network.o abcs_protocol.o abcs_settings.o abcs_client.o abcs_driver.o moc_abcs_core.o -F/Users/andy/Qt/5.2.0/clang_64/lib -framework QtSql -framework QtCore -framework QtNetwork -framework QtXml
        ln -s libabcsCore.1.0.0.dylib libabcsCore.dylib
        ln -s libabcsCore.1.0.0.dylib libabcsCore.1.dylib
        ln -s libabcsCore.1.0.0.dylib libabcsCore.1.0.dylib
        cp -f /Users/andy/src/abcs/libs/trunk/core/abcs_core.h /usr/include/
        cp -f "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.1.0.0.dylib"
        ln -f -s "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.dylib"
        ln -f -s "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.1.dylib"
        ln -f -s "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.1.0.dylib"
        </snip>@

        Second phase error:

        @/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -single_module -dynamiclib -compatibility_version 1.0 -current_version 1.0.0 -install_name libabcsWidgets.1.dylib -o libabcsWidgets.1.0.0.dylib abcsPushBtn.o abcsStatusLabel.o abcsClocks.o abcsclientwidget.o abcsFader.o abcsFaderControl.o abcsDial.o abcsDestButton.o abcsDestGrid.o abcsSourceButton.o abcsSourceGrid.o abcsGestureScroller.o abcsSmartButton.o abcsKeypad.o qrc_abcsWidgets.o moc_abcs_widgets.o -F/Users/andy/Qt/5.2.0/clang_64/lib -L/usr/lib -labcsCore -framework QtWidgets -framework QtGui -framework QtCore -framework QtXml -framework QtSql -framework QtNetwork -framework OpenGL -framework AGL
        ld: library not found for -labcsCore
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make[1]: *** [libabcsWidgets.1.0.0.dylib] Error 1
        make: *** [sub-widgets-install_subtargets] Error 2
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The command line looks fine to me. Can you try with a minimal project that uses libabcsCore ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            marria01
            wrote on last edited by
            #5

            Just tried building an application via the Creator wizard. An app with a single QWidget. Once I add
            @LIBS += -L/usr/lib -labcsCore@
            to the project file I get the same error as before.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What does

              @ls -la /usr/lib/libabcsCore*@

              return ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                marria01
                wrote on last edited by
                #7

                Sorry for taking so long to reply:

                @ls -la /usr/lib/libabcsCore*
                -rwxr-xr-x 1 root wheel 251548 26 Dec 22:25 /usr/lib/libabcsCore.1.0.0.dylib
                lrwxr-xr-x 1 root wheel 23 26 Dec 22:25 /usr/lib/libabcsCore.1.0.dylib -> libabcsCore.1.0.0.dylib
                lrwxr-xr-x 1 root wheel 23 26 Dec 22:25 /usr/lib/libabcsCore.1.dylib -> libabcsCore.1.0.0.dylib
                lrwxr-xr-x 1 root wheel 23 26 Dec 22:25 /usr/lib/libabcsCore.dylib -> libabcsCore.1.0.0.dylib
                @

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I just realized, is it me or is -L/usr/lib missing from your linker line ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    marria01
                    wrote on last edited by
                    #9

                    I think it might be you. ;-)

                    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -single_module -dynamiclib -compatibility_version 1.0 -current_version 1.0.0 -install_name libabcsWidgets.1.dylib -o libabcsWidgets.1.0.0.dylib abcsPushBtn.o abcsStatusLabel.o abcsClocks.o abcsclientwidget.o abcsFader.o abcsFaderControl.o abcsDial.o abcsDestButton.o abcsDestGrid.o abcsSourceButton.o abcsSourceGrid.o abcsGestureScroller.o abcsSmartButton.o abcsKeypad.o qrc_abcsWidgets.o moc_abcs_widgets.o -F/Users/andy/Qt/5.2.0/clang_64/lib -L/usr/lib -labcsCore -framework QtWidgets -framework QtGui -framework QtCore -framework QtXml -framework QtSql -framework QtNetwork -framework OpenGL -framework AGL

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Did you try to link to your library by hand on the command line ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        marria01
                        wrote on last edited by
                        #11

                        You mean run the same command from the terminal? Yes, I get the same error.

                        Given the same code is compiling under Linux and Windows without issue, I'm inclined the think it's a bug in Qt/clang++.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          No sorry, I meant create a dummy main using a function of your library and call clang by hand to compile/link to see it still has the same problem

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          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