Wt with Qt, .pro settings - qt

I am trying to get Wt working with Qt. I have installed 1.47 boost library, compiled Wt (3.2.1) under Windows using cmake 2.8.8. Tired simple hello world but doesn't compile, getting undefined reference errors for example:
undefined reference to `Wt::WApplication::WApplication(Wt::WEnvironment const&, Wt::WtLibVersion)'
Here is my .pro file:
QT -= core
QT -= gui
INCLUDEPATH += ../../../lib/Wt/include \
../../../lib/boost_1_47 \
../../../lib/Wt/src
LIBS += -L../../../lib/Wt/lib \
-L../../../lib/boost_1_47/lib
win32:LIBS += -lwthttpd -lwtd -lboost_regex-vc100-mt-1_47
TARGET = HttpServerWt
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
This is the program I am trying to compile:
http://www.webtoolkit.eu/wt/src/hello

Probably, your WT libraries will be added to /usr/loca/lib by default. so specify link libraries accordingly[after checking whether its present there, else check in /usr/lib and include accordingly].
Set LIBS Variable as follows
LIBS += -L/usr/local/lib -lwtd -lwthttpd -lboost_regex-vc100-mt-1_47
I don't see any Problem in setting the INCLUDEPATH variable in your post.
And also make sure that you are adding the module corresponding to Wt::WApplication::WApplication(Wt::WEnvironment const&, Wt::WtLibVersion) in LIBS Variable.
For more look here.

I think you need more libraries, because in Ubuntu you need to add more than two libraries to compile a wt code with qt creator.
Here is my *.pro file
QT += core
QT -= gui
TARGET = prueba3
LIBS += -L/usr/lib -lwt -lwthttp -I/usr/local/include
LIBS += -L/usr/local/lib -lwthttp -lwt -lboost_regex -lboost_signals
LIBS += -lboost_system -lboost_thread -lboost_filesystem -lboost_date_time
#QMAKE_CXXFLAGS += -DNDEBUG
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
and it compiles/Build great, finally you must add this line to run settings(ctrl+5)
--docroot . --http-address 0.0.0.0 --http-port 9090

Related

qtcreator project file depndancies and build order

I am using qtcreator with subdir project structure. The case is that:
I have 2 projects. Project A and B. After A compiles, then B, but in B, I must use the headers of A (classes, functions, etc.). I`ve found in wiki the depends and subdir project setup, but when I try to include class A from project A into class B into project B ( these names are for convininece ) it gives me undefined referencies. Here is my .pro file from main project (and subprojects respectively ):
#base pro file
TEMPLATE = subdirs
SUBDIRS += \
message \
daemon \
receiver
daemon.subdir = daemon
message.subdir = message
daemon.depends = message
subproject A:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
daemon.cpp \
logwriter.cpp
HEADERS += \
daemon.h \
logwriter.h \
defs.h
LIBS += -lpthread
subproject B:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
message.cpp \
main.cpp
HEADERS += \
message.h
So I need the project B classes into project A and further on when I extend the project.
Regards.
EDIT: A .pri example would be appreciated, if I'm going to set project A to be a library (-lclssA )
"undefined references" are generally link problems, not header include problems. You may have to link your project A with B if you need to use it.
e.g in A :
LIBS += ../path/to/libB.so
The simplest way is to include it as a lib, the easiest way was from qtcreator, rightclick on the dependee and "Add library" -> "Existing library from build tree". This will generate the following in the .pro:
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../message/release/ -lmessage
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../message/debug/ -lmessage
else:unix: LIBS += -L$$OUT_PWD/../message/ -lmessage
INCLUDEPATH += $$PWD/../message
DEPENDPATH += $$PWD/../message
However I am losing the ability to make tests for my message class in it's main class. So if there is a better way, I'd accept it.

Qt error: undefined reference to 'QDebug::~QDebug()'

I am compiling my code with caffe, opencv 3.1 and Qt5.6. Following is my .pro file. I have not included the actual source and header file names here.
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = outsideSituationDetection
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
<and others>
HEADERS += mainwindow.h \
< and others >
FORMS += mainwindow.ui
DEFINES += CPU_ONLY
QMAKE_CXXFLAGS += -std=c++11 -Wall -D_REENTRANT -D__STDC_CONSTANT_MACROS -pthread
QMAKE_CXXFLAGS += -DQT_COMPILING_QSTRING_COMPAT_CPP -DQT_COMPILING_QIMAGE_COMPAT_CPP
CONFIG += link_pkgconfig
PKGCONFIG += opencv
INCLUDEPATH += /usr/local/include /usr/local/lib /usr/lib
DEPENDPATH += /usr/local/include
LIBS += -L/usr/local/lib/ -lopencv_imgproc
LIBS += -lm -lglib-2.0 -lgthread-2.0 -lxml2 -pthread
INCLUDEPATH += /usr/include/glib-2.0
INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include
INCLUDEPATH += /usr/include/libxml2
INCLUDEPATH += /usr/include/ \
/usr/lib/x86_64-linux-gnu/ \
LIBS += -L/usr/lib/x86_64-linux-gnu/ -lglog -lpthread -lm -lrt -ldl -lnsl
DEPENDPATH += /usr/lib/x86_64-linux-gnu/
# BOOST Library
LIBS += -L/usr/lib/x86_64-linux-gnu/ -lboost_system
INCLUDEPATH += /usr/lib/x86_64-linux-gnu
#Caffe for CPU System
INCLUDEPATH += $$PWD/../../../../../src/caffe/build/include \
$$PWD/../../../../../src/caffe/include \
$$PWD/../../../../../src/caffe/build
unix:!macx: LIBS += -L$$PWD/../../../../../src/caffe/build/lib/ -lcaffe -lglog
INCLUDEPATH += $$PWD/../../../../../src/caffe/build
DEPENDPATH += $$PWD/../../../../../src/caffe/build
RESOURCES += icons.qrc
Problem - When I compile the code, I get a bunch of 'error: undefined reference to 'QDebug::~QDebug()'' errors along with 'error: undefined reference to `QDebug::putString(QChar const*, unsigned long)'' against all of my .cpp files. (I have successfully built and executed another application without errors using Qt5.6 and Qt5.7.)
(.qtversion[qt_version_tag]+0x0):-1: error: undefined reference to `qt_version_tag' File not found (.qtversion[qt_version_tag]+0x0) in main.o
What I have tried - Check Qt version to make sure I am using Qt5.6. Deleted the installed qt5-default by doing 'sudo apt-get remove qt5-default'. Downgraded from Qt5.7 to Qt5.6 although it didn't make any difference. I have deleted qt4 and qt5 folders from /usr/include and /usr/share.
Can you please suggest what I might be missing?
I had multiple declarations of ' #include "QDebug" ' in files. Removing them and having it in only one file removed the error. (edit- it's incorrect and doesn't work)
What worked - Though I had removed older versions of Qt 3, 4 & 5 , qt was internally using 5.2.1 versions. I do not know where they came from. But when I deleted them all in /usr/lib/x86_linux_gnu/, the code compiled! I also specified the paths to the installed directory explicitly in qtchooser/default.conf. This may not be the best way to do but it worked anyway.

Qt in Ubuntu: Cannot compile using static boost libraries

I am trying to compile a C++ plugin using Ubuntu 14.04, Qt, and some boost libraries.
I built the boost libraries as follows:
libboost-all-dev
If I use shared boost libraries, e.g. libboost_system.so, the project compiles just fine. However, I want to compile using static boost libraries (libboost_system.a). I get the following error in my boost project:
"relocation R_X86-64-32 against '.rodata.str1.1' cannot be used when making a shared object; recompile with -fPIC".
This is my Qt project file:
VERSION = 1.3.1
TEMPLATE = lib
QT -= gui
CONFIG += warn_on plugin release
CONFIG -= thread exceptions qt rtti debug
CONFIG += c++11
INCLUDEPATH += /usr/include
LIBS += "/usr/lib/x86_64-linux-gnu/libboost_system.a"
LIBS += "/usr/lib/x86_64-linux-gnu/libboost_filesystem.a"
DEFINES += APL=0 IBM=0 LIN=1
DEFINES += IGOCONNECT_LIN_LIBRARY
TARGET = lin.xpl
QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_CXXFLAGS += -fPIC
SOURCES += igoconnect_lin.cpp
HEADERS +=
unix {
target.path = /usr/lib
INSTALLS += target
}
Anything I am doing wrong? Thank you so much!
Try that
LIBS += -lboost_system

Qt: cannot find DLLs even if I specify their location

I cannot understand why this Qt pro file does not work:
QT += core
QT += gui
TARGET = PrjName
CONFIG += qt
CONFIG += console
TEMPLATE = app
INCLUDEPATH += C:/Qt/4.8.4/include/Qt
QMAKE_LIBDIR += C:/Qt/4.8.4/bin
LIBS += -lQtCore4
LIBS += -lQtGui4
SOURCES += ...
HEADERS += ...
These are the linker errors:
error: cannot find -lQtGui
error: cannot find -lQtCore
The C:\Qt\4.8.4\bin directory exists, and the DLLs are there.
Thank you.
Platform: Windows 7, MinGW, Qt 4.8.4, QtCreator 2.8.0

Linking dll to c++ in qt for reading .mat files

I am using Qt Creator 2.4.1(Based on Qt 4.7.4) ..
Now I want to open the .mat file which I got from Matlab.
I am using the basic function matOpen
Initially, I knew the headers required. They are mat.h, matrix.h and tmw.h.
Now, before running the code, I need to link the libraries. The required libraries as far as I know are libmat.dll and libmw.dll . I added them to the .pro file as follows.
QT += core
QT -= gui
TARGET = mat_open_test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += \
mat.h \
matrix.h \
tmwtypes.h
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop- Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\libmat.dll"
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\libmx.dll"
Still I get error as : undefined reference to matOpen.. m sure the problem is with the linking.. But I dunno how to solve it. and the compiler Qt is using is MinGw .
You are specifying library path only, not the libraries itself. Try
LIBS += -L"C:\Users\skanduri\Documents\C ++\mat_open_test-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug"
LIBS += -llibmx
LIBS += -llibmat

Resources