How Can I link custom .dylib library in to another project in iOS?
-
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.dylibWhat 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.
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_staticDACJust for Note: ChargeDischargeDC2 is not my main project.
-
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 yourLIBS
instruction in your .pro file. -
As I mention in ChargeDischarge2 .pro file I link SquidstateLibrary with help of two steps.
- set the include Path
./../../../../DllFileCreator/SquidStateLibrary \
- 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 inDESTDIR = ../../out/Release/squidstatelibrary
libSquidStateLibrary.1.0.0.dylib
libSquidStateLibrary.1.0.dylib
libSquidStateLibrary.1.dylib
libSquidStateLibrary.dyliband 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.