Libharu explain link in QT c++ - c++

I download libharu.zip, try to include it into QT creator c++.
But I don't have lib*.a files in libharu. What do I need to do? It has some makefiles etc.
I find some info about makefile, but don`t understand how it works in QT creator.
nmake -f Makefile.win
What do I need to run this command?

You will need a .so or a .a for linking, in qt creator edit your .pro:
INCLUDEPATH += <path_to_lib>/your_lib_include
When you have a .so for linking:
LIBS += -L<path_to_lib> -l<libname>
When you have a .a for linking:
LIBS += <path_to_lib>/libname.a

Related

How to add an hdf5 to a Qt-Project?

Situation:
I need to add a library (HDF5 in my case) to my qt project.
I know how to code c++ enough for my purposes, but i have no clue about the .pro file. When i try to google my problem or general guides for adding libraries i find lots of answers but understand none of them, because they require more knowledge then i have. They say stuff like "compile it here and there", "add this and that to your system", "use qmake in directory xyz". Can someone please answer the question so that one who only knows a bit of c++ and the green compile & run button of qt understands it? Would be great :-)
What I tired:
I know that there is a wizarb in qt that can add librarys to projects. I used it to add the libraries needed. I added them as "external librarys".
I tried as dynamic or static, i tried adding only the hdf5.lib or the hdf5_cpp.lib too.
Problem:
When I do it as I described above and try to use a function from the added library i always get errors like: undefined reference to H5::Function_Name_xyz.
My .pro looks like (generated by the qt add-library-wizard):
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp
#Add external static library "hdf5.lib":
unix|win32: LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5
INCLUDEPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
DEPENDPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
win32:!win32-g++: PRE_TARGETDEPS += 'C:/Program Files/HDF_Grou/HDF5/1.10.2/lib/hdf5.lib'
#Add external static library "hdf5_cpp.lib"
unix|win32: LIBS += -L'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/' -lhdf5_cpp
INCLUDEPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
DEPENDPATH += 'C:/Program Files/HDF_Group/HDF5/1.10.2/include'
win32:!win32-g++: PRE_TARGETDEPS += 'C:/Program Files/HDF_Group/HDF5/1.10.2/lib/hdf5_cpp.lib'
Using:
C++
Qt 5.10.1
MinGW 32bit
HDF5 1.10.2
Windows 7
I had this same issue awhile back. I did the following to correct the linking error.
Make sure you run qmake (Build-> Run qmake) after adding a new library to the .pro file.
Since you are using windows with the pre-built HDF library, you should use the MSVC2015 32 bit Build&Run kit. The pre-built libraries used Microsoft Visual C++ compiler, so to use the HDF libraries you will need to use that compiler.
Per the HDF documentation, you need to list the external libraries first. The following snippit shows my setup using dynamic libraries.
If your using dynamic libraries be sure to add DEFINES += H5_BUILT_AS_DYNAMIC_LIB to your .pro file.
win32: LIBS += -L$$PWD/'../../../../../Program Files/HDF_Group/HDF5/1.10.4/lib/' -lszip -lzlib -lhdf5 -lhdf5_cpp
INCLUDEPATH += $$PWD/'../../../../../Program Files/HDF_Group/HDF5/1.10.4/include'
DEPENDPATH += $$PWD/'../../../../../Program Files/HDF_Group/HDF5/1.10.4/include'

Linking libtensorflow_cc.so file to QT project

I want to use tensorflow_cc library in QT creater
I tried linking the libtensorflow_cc.so in .pro file but I'm still unable to access the header files.
test.pro file:
LIBS += -L/usr/local/lib/ -ltensorflow_cc
INCLUDEPATH += /usr/local/lib/
test.cpp file:
#include <tensorflow/core/platform/env.h>
error :
tensorflow/core/platform/env.h: No such file or Directory
I have added the path of the .so file to LD_LIBRARY_PATH. Is there anyway to include the tensorflow library and use the header files in QT.
This is a similar question but it didn't quite help me.
Thanks!
Add this to the .pro file:
LIBS += /usr/lib/libtensorflow_cc.so

QMAKE: Link static library against another static library

I have a QMAKE staticlib project (libtest.a) that deppends to ther subproject (liblogger.a)
I try to add his to test.pro:
LIBS += -L$$OUT_PWD/../libs/logger/ -llogger
PRE_TARGETDEPS += $$OUT_PWD/../libs/logger/liblogger.a
but, finaly, qmake pack .a library without liblogger.a
ar cqs libtest.a libtest.o
I can't use QMAKE_AR += or QMAKE_LIBFLAGS +=, and I need to build static library with this AR command
ar cqs libtest.a libtest.o ../libs/logger/liblogger.a
any idea?
One possible strategy is to add a custom build target that depends on both your project (libtest.a) and the subproject (liblogger.a), which outputs the unified library you're looking for by calling ar.
You can check qmake's documentation here.
Afterwards, set that custom build step as a dependency of the project that includes main().

link boost libs to qt with msvc

I have installed qt-opensource-windows-x86-msvc2013_64_opengl-5.4.0.exe and compiled boost_1_58_0.zip with this command: b2 toolset=msvc --build-type=complete stage. It works fine with Visual Studio, but when I try use it with Qt I get this error:
:-1: error: LNK1104: cannot open file 'libboost_filesystem-vc120-mt-gd-1_58.lib'
Here is my .pro file:
TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp \
testclass.cpp
RESOURCES += qml.qrc
INCLUDEPATH += C:\boost
LIBS += "-LC:\boost\stage\lib\libboost_filesystem-vc120-mt-gd-1_58.lib"
#Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
HEADERS += \
testclass.h
In the LIBS variable use just "-L" for correct library path (-L). You made a mix, specifying a file (lowercase l) while libs directory is missing.
You do not need to specify the library, boost has pragmas for that.

How can I make QtCreator compile with gsl library?

I am trying to use the GNU Scientific Library (GSL) http://www.gnu.org/software/gsl/ in QtCreator. How can I tell Qt creator to add these flags: http://www.gnu.org/software/gsl/manual/html_node/Linking-programs-with-the-library.html to link correctly?
You need to edit your .pro file and add the extra libs by hand, e.g.:
LIBS += -L/usr/local/lib example.o -lgsl -lgslcblas -lm
See the QMake documentation for more information.
Edit your .pro file and extra libs and include in windows:
`win32{
INCLUDEPATH += C:/gsl-1.11/include/
INCLUDEPATH += C:/gsl-1.11/lib
LIBS += -LC:/gsl-1.11/bin -llibgsl-0 -llibgslcblas-0
}`
then the problem is solved