Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. How Can I link custom .dylib library in to another project in iOS?
QtWS25 Last Chance

How Can I link custom .dylib library in to another project in iOS?

Scheduled Pinned Locked Moved Solved 3rd Party Software
3rd partymacoslink errordylib
4 Posts 2 Posters 3.2k 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.
  • Y Offline
    Y Offline
    Yash001
    wrote on last edited by Yash001
    #1

    Hello,

    I am using MAC and window both system.

    OS: Windows 10
    Tool: visual studio 2017, and QT.
    I create one of the Custom Library, Its name is SquidstateLibrary. I am able to build and run SquidStateLibrary. I am using SquidstateLibrary.dll file and SquidstateLibrary.lib file into ChargeDischarge2 project.

    I copy SquidStateLibrary.dll file in out put directory of ChargeDischarge2 by post -build event in visual studio. ChargeDischarge2 project work fine (I am able to build).

    OS: IOS
    Tool: Qt
    How can I do same thing on IOS? I am able build the SquidStateLibrary and generate .dylib files in output directory.
    libSquidStateLibrary.1.0.0.dylib
    libSquidStateLibrary.1.0.dylib
    libSquidStateLibrary.1.dylib
    libSquidStateLibrary.dylib

    What are the other steps require to use the .dylib file in ChargeDischarge2 project on IOS?

    what are the modification require in .pro file?
    where do I need to set the path for script in ChargeDischarge2 Project?
    (script for: copy the SquidStatelLibrary.dylib file in to MacOs/contain file).

    Here SquidStateLibrary .pro file

    # ----------------------------------------------------
    # This file is generated by the Qt Visual Studio Tools.
    # ------------------------------------------------------
    
    TEMPLATE = lib
    TARGET = SquidStateLibrary
    DESTDIR = ../../out/Release/squidstatelibrary
    QT += core
    CONFIG += release shared dll
    DEFINES += WIN64 SQUIDSTATELIBRARY_LIB
    INCLUDEPATH += ./../../SquidStat \
        ./GeneratedFiles \
        . \
        ./GeneratedFiles/Release \
        ./../../_arduino\retrofit_firmware
    DEPENDPATH += .
    MOC_DIR += ./GeneratedFiles/release
    OBJECTS_DIR += release
    UI_DIR += ./GeneratedFiles
    RCC_DIR += ./GeneratedFiles
    include(SquidStateLibrary.pri)
    

    SquidStateLibrary.pri file

    # ----------------------------------------------------
    # This file is generated by the Qt Visual Studio Tools.
    # ------------------------------------------------------
    
    # This is a reminder that you are using a generated .pro file.
    # Remove it when you are finished editing this file.
    message("You are running qmake on a generated .pro file. This may not work!")
    
    
    HEADERS += ./squidstatlibrary.h \
        ./squidstatlibrary_global.h
    SOURCES += ./squidstatlibrary.cpp
    

    ChargeDischarge2 .pro file

    # ----------------------------------------------------
    # This file is generated by the Qt Visual Studio Tools.
    # ------------------------------------------------------
    
    TEMPLATE = lib
    TARGET = ChargeDischarge2
    DESTDIR = ../../../../out/Release/prebuilt
    QT += core gui designer widgets
    CONFIG += release designer plugin
    DEFINES += QT_DESIGNER_LIB QT_WIDGETS_LIB
    INCLUDEPATH += ./../../../../_arduino/retrofit_firmware \
        ./../../SquidStat \
        ./GeneratedFiles \
        . \
        ./GeneratedFiles/Release \
        ./../../../../DllFileCreator/SquidStateLibrary \
    LIBS += -L"./../../../../out/Release/squidstatelibrary" \
        -lSquidStateLibrary
    DEPENDPATH += .
    MOC_DIR += ./GeneratedFiles/release
    OBJECTS_DIR += release
    UI_DIR += ./GeneratedFiles
    RCC_DIR += ./GeneratedFiles
    include(ChargeDischarge2.pri)
    
    #Install the plugin in the designer plugins directory.
    target.path = $$[QT_INSTALL_PLUGINS]/designer
    INSTALLS += target
    

    ChargeDischarge2.pri file

    # ----------------------------------------------------
    # This file is generated by the Qt Visual Studio Tools.
    # ------------------------------------------------------
    
    # This is a reminder that you are using a generated .pro file.
    # Remove it when you are finished editing this file.
    message("You are running qmake on a generated .pro file. This may not work!")
    
    
    HEADERS += ./Factory.h \
        ./ChargeDischargeDC2.h
    SOURCES += ./ChargeDischargeDC2.cpp \
        ./Factory.cpp
    RESOURCES += recources.qrc
    

    getting Error while trying to build ChargeDischarge2 project.

    0_1531174422363_Screen Shot 2018-07-09 at 3.12.36 PM.png

    Complier Output:

    15:12:18: Running steps for project SquidStat...
    15:12:18: Starting: "/Users/admiralinstruments/Qt/5.6.3/clang_64/bin/qmake" /Users/admiralinstruments/Documents/Potentiostat/src/SquidStat/Experiments/ChargeDischargeDC2/ChargeDischarge2.pro -spec macx-clang CONFIG+=x86_64
    Project MESSAGE: You are running qmake on a generated .pro file. This may not work!
    Project WARNING: CONFIG+=designer is deprecated. Use QT+=designer instead.
    15:12:19: The process "/Users/admiralinstruments/Qt/5.6.3/clang_64/bin/qmake" exited normally.
    15:12:19: Starting: "/usr/bin/make" qmake_all
    make: Nothing to be done for `qmake_all'.
    15:12:19: The process "/usr/bin/make" exited normally.
    15:12:19: Starting: "/usr/bin/make" 
    rm -f libChargeDischarge2.dylib
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.7 -Wl,-rpath,/Users/admiralinstruments/Qt/5.6.3/clang_64/lib -single_module -dynamiclib -o libChargeDischarge2.dylib release/ChargeDischargeDC2.o release/Factory.o release/qrc_recources.o release/moc_Factory.o  -F/Users/admiralinstruments/Qt/5.6.3/clang_64/lib -framework QtDesigner -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework QtXml -framework OpenGL -framework AGL  
    Undefined symbols for architecture x86_64:
      "SquidstatLib::GetUnitsMultiplier(QString)", referenced from:
          ChargeDischargeDC2::GetNodesData(QWidget*, cal_t const&, HardwareVersion const&) const in ChargeDischargeDC2.o
      "SquidstatLib::ProcessDCDataPoint(cal_t const*, ExperimentalDataPoint_t)", referenced from:
          AbstractExperiment::PushNewDcData(ExperimentalDataPoint_t const&, QMap<QString, DataStore>&, cal_t const&, HardwareVersion const&, ExperimentNotes const&, AbstractExperimentTrigger*) const in ChargeDischargeDC2.o
      "SquidstatLib::GetSamplingParams_staticDAC(HardwareModel_t, ExperimentNode_t*, double, double)", referenced from:
          ChargeDischargeDC2::GetNodesData(QWidget*, cal_t const&, HardwareVersion const&) const in ChargeDischargeDC2.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [../../../../out/Release/prebuilt/libChargeDischarge2.dylib] Error 1
    15:12:20: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project SquidStat (kit: Desktop Qt 5.6.3 clang 64bit)
    When executing step "Make"
    15:12:20: Elapsed time: 00:02.
    
    

    Funcation Define in to Library:

    SquidstatLib::GetUnitsMultiplier
    SquidstatLib::ProcessDCDataPoint
    SquidstatLib::GetSamplingParams_staticDAC

    Just for Note: ChargeDischargeDC2 is not my main project.

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

      Hi,

      How are you linking to them in your project ?

      The same rules applies to all platform for libraries: add the -L/path/to/folder/of/lib and -lnameoflib to your LIBS instruction in your .pro file.

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

        As I mention in ChargeDischarge2 .pro file I link SquidstateLibrary with help of two steps.

        1. set the include Path
        ./../../../../DllFileCreator/SquidStateLibrary \
        
        1. set the library folder path
        LIBS += -L"./../../../../out/Release/squidstatelibrary" \
            -lSquidStateLibrary
        

        The Only Different is that On Windows system I build the Squidstatelibrary with help of visual stuido 2017, and generate the .dll and .lib. and with help of post build event I copy the .dll file into

        DESTDIR = ../../../../out/Release/prebuilt
        

        On mac system, I build the Squidstatelibrary with help of Qt software, and it is generate
        four .dylib file in

        DESTDIR = ../../out/Release/squidstatelibrary
        

        libSquidStateLibrary.1.0.0.dylib
        libSquidStateLibrary.1.0.dylib
        libSquidStateLibrary.1.dylib
        libSquidStateLibrary.dylib

        and manually copy into the libSquidStateLibrary library file into

        DESTDIR = ../../../../out/Release/prebuilt
        

        I read some of place for Mac version, I may need to create myapp.app package, and use command "install_name_tool". As this per my understanding, I need to use this steps while deploying application for mac, so that I do not require to use this steps at this time, Please correct me if I am wrong.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          Yash001
          wrote on last edited by Yash001
          #4

          @SGaist Thank you sir for your advise. I solve this issue. By mistake, I put the " \ (backward slash)" before LIBS variable in ChargeDischarge2 .pro file. Now project ChargeDischarge2 is build.

          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