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. Static linking on Mac OS ?
QtWS25 Last Chance

Static linking on Mac OS ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.4k Views
  • 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
    maximus
    wrote on last edited by
    #1

    Hi guys,

    I'm trying to port my windows Qt app to Mac OS.
    My project use an external library, on windows I did compile this external library myself to "Ant_lib.lib" and use that lib for compile in my main project.

    On Mac OS, I did the same thing, I compiled the external lib to "libANT_LIB.a" and then try to use it to compile my main project. However, I get some error on the compile.
    I heard that you cannot static link libraries on mac OS, is it true? "source":http://nelsonslog.wordpress.com/2013/04/24/macos-doesnt-support-static-binaries/

    Here is the .pro file used to compile the static library :

    @QT -= gui

    TARGET = ANT_LIB
    TEMPLATE = lib

    CONFIG += staticlib
    CONFIG += release

    include (common/common.pri)
    include (inc/inc.pri)
    include (software/ANTFS/ANTFS.pri)
    include (software/serial/serial.pri)
    include (software/serial/device_management/device_management.pri)
    include (software/system/system.pri)
    include (software/USB/USB.pri)
    include (software/USB/device_handles/device_handles.pri)
    include (software/USB/devices/devices.pri)
    include (software/USB/iokit_driver/iokit_driver.pri)@

    For the record, here are the errors i'm getting when building my main project :

    @Undefined symbols for architecture x86_64:
    "_CFDictionarySetValue", referenced from:
    USBDeviceHandleSI::GetAllDevices() in libANT_LIB.a(usb_device_handle_vcp.o)
    USBDeviceHandleSI::FindModems(unsigned int*) in libANT_LIB.a(usb_device_handle_vcp.o)
    "_CFNumberGetValue", referenced from:
    USBDeviceSI::USBDeviceSI(unsigned int const&) in libANT_LIB.a(usb_device_vcp.o)
    USBDeviceSI::GetDeviceNumber(unsigned int const&, __CFString const*) in libANT_LIB.a(usb_device_vcp.o)@

    └(°ᴥ°)┘ Thanks if you can direct a newbie Mac user! └(°ᴥ°)┘


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      For me it looks like a compiler can not find the fucntions that are used in libANT_LIB.a but not defined anywhere.
      Do you have the functions _CFDictionarySetValue and _CFNumberGetValue defined somewhere in your project or in the external libraries?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        I looked at CFNumber functions. They are a part of
        "OS X CoreFoundation framework":https://developer.apple.com/library/mac/documentation/corefoundation/Reference/CFNumberRef/Reference/reference.html

        Maybe you should add CoreFoundation as an external library in you project.

        I've never used QtCreator with OS X specific functions so can not help here.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on last edited by
          #4

          Thanks I figured I was missing some libraries.

          I added theses 2 libs in my main project .pro
          LIBS += -framework IOKit
          LIBS += -framework CoreFoundation

          now the _CFDictionarySetValue errors and friends are gone!
          With this I reduced the list of errors from ~150 to a few left :)

          Here are the last one, hopefully I can figure those one also

          @ "std::_List_node_base::hook(std::_List_node_base*)", referenced from:
          IOKitDeviceHandle::SendSyncControlTransfer(unsigned char, unsigned char, unsigned short, unsigned short, unsigned char*, unsigned short, unsigned int, int&) in libANT_LIB.a(iokit_device_handle.o)
          IOKitDeviceHandle::SendSyncInterruptTransfer(unsigned char, unsigned char*, int, unsigned int, int&) in libANT_LIB.a(iokit_device_handle.o)
          IOKitDeviceHandle::SendSyncBulkTransfer(unsigned char, unsigned char*, int, unsigned int, int&) in libANT_LIB.a(iokit_device_handle.o)
          "std::_List_node_base::unhook()", referenced from:
          IOKitDeviceHandle::SendSyncControlTransfer(unsigned char, unsigned char, unsigned short, unsigned short, unsigned char*, unsigned short, unsigned int, int&) in libANT_LIB.a(iokit_device_handle.o)
          IOKitDeviceHandle::SendSyncInterruptTransfer(unsigned char, unsigned char*, int, unsigned int, int&) in libANT_LIB.a(iokit_device_handle.o)
          IOKitDeviceHandle::SendSyncBulkTransfer(unsigned char, unsigned char*, int, unsigned int, int&) in libANT_LIB.a(iokit_device_handle.o)
          "std::__throw_length_error(char const*)", referenced from:
          std::vector<USBDevice const**, std::allocator<USBDevice const**> >::_M_insert_aux(__gnu_cxx::__normal_iterator<USBDevice const***, std::vector<USBDevice const**, std::allocator<USBDevice const**> > >, USBDevice const** const&) in libANT_LIB.a(usb_device_handle_mac.o)
          std::vector<USBDeviceIOKit const**, std::allocator<USBDeviceIOKit const**> >::_M_insert_aux(__gnu_cxx::__normal_iterator<USBDeviceIOKit const***, std::vector<USBDeviceIOKit const**, std::allocator<USBDeviceIOKit const**> > >, USBDeviceIOKit const** const&) in libANT_LIB.a(usb_device_handle_mac.o)@


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andreyc
            wrote on last edited by
            #5

            "This maybe the case with std:: errors":http://stackoverflow.com/questions/12920891/std-linker-error-with-apple-llvm-4-1

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maximus
              wrote on last edited by
              #6

              oh nice I fixed it using this:

              changing ../Qt5.2.0/5.2.0-rc1/clang_64/mkspecs/macx-clang/qmake.conf
              from
              QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
              to
              QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
              "source":http://stackoverflow.com/questions/20342896/solved-qt5-1-qt5-2-mac-os-10-9-mavericks-xcode-5-0-2-undefined-symbols

              also added this to both of my project (static lib and the main project)
              CONFIG += c++11
              CONFIG += x86_64
              CONFIG -= i386

              Then recompiled and error are gone, thanks!


              Free Indoor Cycling Software - https://maximumtrainer.com

              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