Ubuntu Qt link boost log - c++

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

Related

Linux: Linking Microsoft/CPPRestSDK via qmake

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

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?

How to avoid automatic adding of /usr/lib64 in Qt pro file

I have a Qt project. I can add some libraries using the commands like:
LIBS += -lopencv_core
They work perfectly for me. However, if I check the output, I have there other libraries, too. For example /usr/lib64, without mentioning this anywhere in the project. How can I avoid that addition?
You can explicity remove these paths. For example, I use that to remove all standard path (lib and includes) :
unix {
LIBS -= -L/usr/lib/
LIBS -= -L/usr/lib64/
LIBS -= -L/usr/lib
LIBS -= -L/usr/lib64
INCLUDEPATH -= /usr/include/
INCLUDEPATH -= /usr/include
}

How to link to SDL2 libraries under Qt Creator

I have compiled the latest SDL2 libraries, obtained from the 'official' mercurial repository, and followed the instructions for the Ubuntu/Linux build.
But Qt creator fails to link the statically built libraries. Here's the qmake script:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
unix:!macx: LIBS += -L/usr/local/lib/libSDL2.a
INCLUDEPATH += /usr/local/include
SOURCES += main.cpp
The linker reports several undefined references, including SDL_Init.
You have to change your LIBS line to this:
LIBS += -L/usr/local/lib -lSDL2
as -L let you define the path where linker looks for libraries to link, while -l defines which library to link to. On Unix systems the library called ASD is represented by a libASD.so file (in this example .so is for shared library, in your case there is .a as it is static library).
EDIT:
I've prepared very simple main.cpp:
#include <SDL/SDL.h>
int main()
{
SDL_Init(SDL_INIT_VIDEO);
return 0;
}
build SDL 2.0.3 as static library with /usr/local prefix and I needed to add 2 other libraries to my .pro file to compile this. Here it is:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
CONFIG -= app_bundle
SOURCES += main.cpp
LIBS += -L/usr/local/lib -lSDL2 -ldl -lpthread
INCLUDES += /usr/local/include
And now it compiles flawlessly.

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