Linux: Linking Microsoft/CPPRestSDK via qmake - c++

I am trying to link cpprestsdk with my Qt Widgets Application via QMake and .pro files.
I tried using cpprestsdk in a standalone demo application with the following part in a CMake-file which works fine:
find_package(Boost COMPONENTS filesystem system REQUIRED)
find_package(cpprestsdk REQUIRED)
target_link_libraries(demo PRIVATE cpprestsdk::cpprest ssh crypto ${Boost_SYSTEM_LIBRARY})
When trying to convert it to QMake/.pro-file like so:
INCLUDEPATH += /usr/include/cpprest
INCLUDEPATH += /usr/include/boost
INCLUDEPATH += /usr/include/boost/filesystem
INCLUDEPATH += /usr/include/boost/system
LIBS += -lcrypto -lssl -lboost_system -lboost_filesystem -pthread -lboost_thread -lboost_chrono /usr/local/lib/libcpprest.so
The project compiles fine but at execution throws following error:
symbol lookup error: <path> undefined symbol: _ZN7utility7details9str_ilessERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_
C++Filt reveals the undefined symbol to be the following function
c++filt _ZN7utility7details9str_ilessERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_
utility::details::str_iless(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
Now, ldd <application> shows me that libcpprest should be linked correctly and I see no unlinked dependencies.
libcpprest.so.2.10 => /usr/local/lib/libcpprest.so.2.10
Where did I went wrong here?

I tryed the sample Getting Started Tutorial
With:
$ sudo apt-get install libcpprest-dev
On QT creator in ubuntu 20.04 and I add:
INCLUDEPATH += /usr/include/cpprest
INCLUDEPATH += /usr/include/boost
INCLUDEPATH += /usr/include/boost/filesystem
INCLUDEPATH += /usr/include/boost/system
LIBS += -lcrypto -lssl -lboost_system -lboost_filesystem -pthread -lboost_thread -lboost_chrono /usr/local/lib/libcpprest.so
from your previous post to the .pro file
it build susscefull

Related

dlib and Qt: building errors

I have installed dlib to have the static library in my computer and i want to use it in a Qt project but the problem is, once the dlib library is linked to my project i can build it and display simple matrix from dlib namespace but if i try to define a deep learning network i got the following error.
/home/jimmy/Desktop/Connected_Robotics_Watson/workco/work/mainWindow.cpp:-1: error: undefined reference to `dlib::cpu::pooling::pooling()'
i am really lost on how to use with Qt.
Here is my .pro file:
QT += network
QT += widgets
TEMPLATE = app
TARGET = Connected
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui
-lopencv_imgcodecs -lopencv_videoio
QMAKE_CXXFLAGS += -std=c++11
PKGCONFIG = dlib-1
# Input
HEADERS += mainWindow.hpp
SOURCES += main.cpp mainWindow.cpp
If i use the library with normal cpp code and use a cmake to compile, evrything works well.
Does someone have an idea on this problem?

Ubuntu Qt link boost log

I try to link the boost 1.55 log library with a Qt *.pro file.
INCLUDEPATH += $$system(echo ${BOOST_INCLUDE_DIR})
LIBS += -L$$system(echo ${BOOST_LIB_DIR})
LIBS += -lboost_system -lboost_filesystem -lboost_thread -lboost_log
I get a reference error with boost log , because I didn't define
-DBOOST_LOG_DYN_LINK
Can anyone tell me how to define this inside the *.pro file?
In my CMake file i can use: ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
What is the corresponding command in qmake?
Use DEFINES:
DEFINES += BOOST_LOG_DYN_LINK

Linking MLPACK, Armadillo and LAPACK/BLAS in Qt Creator Project in Windows 7

I am trying to integrate MLPACK with my project in Qt Creator (using MinGW as a compiler) and I keep getting linking errors related to LAPACK and Armadillo.
I compiled LAPACK and BLAS myself and run a test script and everything seems to be good there. Also, I compiled Armadillo (without the wrapper) using CMake-gui with LAPACK and BLAS enabled and example1.cpp compiles and runs with no problem.
MLPACK compiles and finds all the needed dependencies.
My .pro file has the following:
## Armadillo
INCLUDEPATH += $$PWD/MLPACK/dependencies/armadillo/include
## LAPACK
unix|win32: LIBS += -L$$PWD/MLPACK/dependencies/lapack/ -llapack
## BLAS
unix|win32: LIBS += -L$$PWD/MLPACK/dependencies/blas/ -lblas
## LibXML2
unix|win32: LIBS += -L$$PWD/MLPACK/dependencies/libxml2/lib/ -lxml2
INCLUDEPATH += $$PWD/MLPACK/dependencies/libxml2/include
DEPENDPATH += $$PWD/MLPACK/dependencies/libxml2/include
unix|win32-g++: PRE_TARGETDEPS += $$PWD/MLPACK/dependencies/libxml2/lib/libxml2.a
## Boost
unix|win32: LIBS += -L$$PWD/../../boost_1_54_0/stage/lib/ -lboost_program_options-mgw48-mt-1_54
INCLUDEPATH += $$PWD/../../boost_1_54_0
DEPENDPATH += $$PWD/../../boost_1_54_0
unix|win32-g++: PRE_TARGETDEPS += $$PWD/../../boost_1_54_0/stage/lib/libboost_program_options-mgw48-mt-1_54.a
unix|win32: LIBS += -L$$PWD/../../boost_1_54_0/stage/lib/ -lboost_random-mgw48-mt-1_54
unix|win32-g++: PRE_TARGETDEPS += $$PWD/../../boost_1_54_0/stage/lib/libboost_random-mgw48-mt-1_54.a
unix|win32: LIBS += -L$$PWD/../../boost_1_54_0/stage/lib/ -lboost_unit_test_framework-mgw48-mt-1_54
unix|win32-g++: PRE_TARGETDEPS += $$PWD/../../boost_1_54_0/stage/lib/libboost_unit_test_framework-mgw48-mt-1_54.a
## MLPACK
unix|win32: LIBS += -L$$PWD/MLPACK/lib/ -lmlpack
INCLUDEPATH += $$PWD/MLPACK/include
DEPENDPATH += $$PWD/MLPACK/include
unix|win32-g++: PRE_TARGETDEPS += $$PWD/MLPACK/lib/libmlpack.a
When I compile my project I am getting this:
C:/Workspace/OffLineSorter/MLPACK/lib//libmlpack.a(pca.cpp.obj):pca.cpp:(.text$_ZN4arma6auxlib11svd_dc_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EE[__ZN4arma6auxlib11svd_dc_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EE]+0x24f): undefined reference to `dgesdd_'
Makefile.Debug:252: recipe for target 'debug\OffLineSorter.exe' failed
C:/Workspace/OffLineSorter/MLPACK/lib//libmlpack.a(pca.cpp.obj):pca.cpp:(.text$_ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc[__ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc]+0x286): undefined reference to `dgesvd_'
C:/Qt/Qt5.3.0/Tools/mingw482_32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: C:/Workspace/OffLineSorter/MLPACK/lib//libmlpack.a(pca.cpp.obj): bad reloc address 0x286 in section `.text$_ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc[__ZN4arma6auxlib8svd_econIdNS_3MatIdEEEEbRNS2_IT_EERNS_3ColIS4_EES6_RKNS_4BaseIS4_T0_EEc]'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [debug\OffLineSorter.exe] Error 1
mingw32-make[1]: Leaving directory 'C:/Workspace/build-OffLineSorter-Desktop_Qt_5_3_0_MinGW_32bit-Debug'
mingw32-make: *** [debug] Error 2
Makefile:34: recipe for target 'debug' failed
Any ideas of what I might be doing wrong?
Thanks for your help!
Can you try with the recently released mlpack 1.0.10? I rewrote the CMake FindArmadillo script so that it properly detects when ARMA_USE_WRAPPER is not being used (which is true in your case) and links directly to LAPACK or BLAS.
It is not tested in your particular setup (MinGW + Win7) because I have not yet had a chance to set up that compilation environment, but I think it should work better.
You may want to consult the mlpack mailing list archives too; there has been some discussion there in the past about the use of MinGW:
https://mailman.cc.gatech.edu/pipermail/mlpack/
Thanks,
Ryan

OpenGL Ubuntu 13.10 QtCreator - undefined reference to `glutMainLoop`

If I try to execute the code from here, the OpenGLBook, I get this error messages:
undefined reference to glutMainLoop
undefined reference to glGetString
undefined reference to glClearColor
and so on ... I installed the following packages:
libglew-dev, liblglew1.8, freeglut3-dev and freeglut3.
I am running on Ubuntu 13.10 with Qt Creator v3.0.0.
My .pro file looks like this:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
Build step for debugging is qmake Project.pro -r -spec linux-g++ CONFIG += debug
How can I fix my project?
Had to change my pro file to
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
# this is the important part
unix|win32: LIBS += -lGLU
unix|win32: LIBS += -lGL
unix|win32: LIBS += -lglut
Welcome to c++ !
You are using a library (freeglut I gather) and for this you need 2 things :
1) include the headers (*.h file(s)) that declare the functions/classes/methods that you need
2) your program needs to link with the actual shared library (.so files in Linux)
In your .pro file you need to specify the path to the libraries you want to link with. Add this :
LIBS += -lglut
It means add the library glut to the list of libraries to link.

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