Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linking an objective-c lib on OS X

Linking an objective-c lib on OS X

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.4k 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.
  • A Offline
    A Offline
    ababeng
    wrote on last edited by
    #1

    Hi,

    I have a Qt gui app for OS X (macx-clang) and a third-party static lib (.a) that was made with objective-c. I don't have access to the lib source, only the headers.

    I can't seem to link with this lib. Any of the lib's functions referenced from the app result in "unknown symbols for architecture x86_64". I've verified that the lib is x86_64 and that it was built with the same version of Clang that we're using. I assume the issue is that it's an obj-c lib.

    I found references in the docs for including mm files but I don't have the source, only the lib and headers. What must I do in order to use the lib successfully?

    Thanks!

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

      Hi and welcome to devnet,

      Can you show how you setup the linking to that library ?

      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
      • A Offline
        A Offline
        ababeng
        wrote on last edited by
        #3

        Thank you.

        Like any other static lib:
        LIBS += $$PWD/libs/problematicLib.a

        Which results in...
        Undefined symbols for architecture x86_64:
        "functionName(param)", referenced from blah

        ... for any function I try to pull in from that lib.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by hskoglund
          #4

          Hi, it looks like you've been bitten by the "changing c++ standard library" syndrome. In OSX 10.9 Apple changed from using libstdc++ to libc++ so most likely your Qt app is built to use libc++ but that third-party static lib is older and built using libstdc++, that's why you get those errors.

          Easiest I think is to tell Qt to build your app in the old way, try inserting CXXFLAGS = -stdlib=libstdc++ in your .pro file. There are plenty of discussions of this, for example here and here

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

            To add to @hskoglund, how are you calling these function exactly ?

            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
            • A Offline
              A Offline
              ababeng
              wrote on last edited by
              #6

              @hskoglund, both the lib and Qt were built with the same version of Clang (clang-703.0.31). stdlib symbols don't appear to be the problem.

              @SGaist, like anything else: include header, call function.

              1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #7

                Just guessing, but if that library was built with Objective-C, and because usually Qt is built as Objective-C++ (i.e. .mm files instead of .m files), perhaps you need to include extern "C" { in the header file for that lib.

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

                  The syntax of Objective-C is not the same as pure C/C++ hence my question. Are you calling them correctly ?

                  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
                  • A Offline
                    A Offline
                    ababeng
                    wrote on last edited by
                    #9

                    QMAKE_LFLAGS += -ObjC

                    ^^ very important

                    Thanks all, working fine now.

                    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