How do I link to Qwt libraries on Ubuntu? - c++

I have installed the Qwt library on Ubuntu 10.04. The Qwt plotting widgets have appeared in QtCreator but when I try to use any of them I get the error:
"qwt_plot.h" no such file or directory.
Can anyone help?
Edit:
I've solved this by implementing Begemoth's answer as follows:
Open the project file (.pro)
Add the following lines to the bottom of the file:
INCLUDEPATH += /usr/include/qwt-qt4
LIBS += -l qwt-qt4

Ubutu like Debian provides several versions of qwt (for qt4 and qt3), so include files for qwt reside in /usr/include/qwt-qt3 or /usr/include/qwt-qt4 directory, you need to add this directory to the list of the include search path, e.g. with -I gcc flag.
PS: I assume that you have installed the development package for qwt (libqwt5-qt4-dev).

Related

Cant find path to QtCore for C++ intellisense in VSCode on ubuntu

tldr: what path do I include in my VScode C++ project to use Qt on ubuntu?
I tried this already : How use Qt in Visual Studio Code?
Having #include <QApplication> in my main.cpp file in VScode, I'm getting cannot open source file "QApplication"C/C++(1696) pop up, and all of my Qt includes in other files have the same or similar problems.
To find my QtCore path I tried the following:
QtCore --version, and a number of other variations of Qt, qt, and QtCore, with no avail.
So I tried this:
xxxxx#xxxx:/$ qmake --version
QMake version 3.1
Using Qt version 5.15.2 in /usr/lib/x86_64-linux-gnu
Which seems great, I need only look in /usr/lib/x86_64-linux-gnu and include the appropriate sub directory in my c_cpp_properties.json file of my VScode C++ project.
But this didn't work.
I tried a number of various Qt related subdirectories here, but none of them seemed to point to the right place.
tldr: what path do I include in my VScode C++ project to use Qt on ubuntu?

z.lib problems while porting qt creator projet to windows

I am trying to port a Qt5.9 project from Mac to Windows 10.
I was able to compile the project easily in a ubuntu installation.
While trying to build it for windows, i had problems with finding zlib include headers with
#include<zlib.h>
That i corrected after following answers here on Stack to
#include<QtZlib/zlib.h>
Now i have problems in LINK phase, it can not open the file z.lib
Problem is i downloaded zlib packages, builds, source code and could not find a z.lib. Only different named libs. Searching in google i could only find people with the same problem, z.lib is not one of the libs included in zlib installation.
This is my project file:
TEMPLATE = app
QT += qml quick widgets websockets
CONFIG += c++11
SOURCES += \
main.cpp \
api.cpp \
app.cpp
HEADERS += \
api.hpp \
app.hpp
RESOURCES += qml.qrc
LIBS += -lz
I tried putting all possible dll and lib files in the project folder. None of them is named z.lib though.
The symbols for zlib are already part of the qt libraries. As long as you do not try to link the zlib explicitly it should work. At least it does work for me.
add to your project file:
!win32 {
LIBS += -lz
}
I managed to solve my problem updating my Qt installation to use MinGw 5.3 32bit. I was using VisualStudio 2015 as the compiler before.
Only changing the compiler to MinGw (g++) 5.3 made everything work with the same pro file i posted in the original question. Thanks everybody who tried to help!

How add Boost Library to QTCreator on RPI2?

I need the boost library for a project on my Raspberry Pi 2. I use QTCreator for coding but I cant add the Library. I tried to add this to the .pro file of my project in QTCreator:
LIBS += -L/usr/include/boost -lboost_chrono
I installed the boost Library using:
sudo apt-get install libboost1.55-all
If I try to compile my code I get the "boost/chrono.hpp no such file or directory".
I read somewhere that I have to compile the Library first using the same compiler as QtCreator (usually mingw) but I have no clue how to do that.(Im a beginner with the raspberry and the linux system in general)
Thx for your help
LIBS += -L
This adds a path to the linker. Your error is related to a path in the include. You should add the boost path via
INCLUDEPATH +=
As mentioned here: How to add include path in Qt Creator?

Qt iOS build does not find headers with path

I am building a working application (Mac and Linux) for iOS emulator in Qt 5.4 but when compiling the sources, compiler shows issues about header files not found. These files definitely are where they should be and the same code/pro builds without issues for desktop versions.
For example, in my code I have included:
#include <sndfile.h>
and in my .pro file I have:
LIBS += -L/usr/local/lib/ -lsndfile.1
INCLUDEPATH += /usr/local/include/
and the header file for libsndfile is definitely in /usr/local/include
I have tried adding this to .pro file
INCLUDEPATH+= $PWD
But no use, still all headers that are not directly in the same folder
as the .pro file cannot be found when compiling... What am I missing?
Is there some different way to define paths to iOS build sources?
I am able to build Qt iOS tutorial projects and run them on the emulator.
Perhaps your Makefile is outdated.
Run qmake again, after changing something in .pro file.

Qt will not link anything

I have tried this both on Ubuntu Linux and on Windows. I can not get Qt to link any of its libraries or any external libraries, I have tried just about every LIBS += -Lpath/to/lib -llib and INCLUDEPATH += path/to/include/files combination possible in my .pro file:
QT += opengl
TARGET = QtOpenGLExample
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
GLExampleWidget.cpp
HEADERS += GLWidget.h
LIBS += -L /usr/lib/ -llibQtOpenGL.so.4.6.2
I noticed this being a problem when I clicked "Open GL" in the project creator and it did not work then (even after I tried messing around in the .pro), before I just thought I was doing something stupid when I tried to link SFML 1.6.
P.s Does it have to do with were my project is located?:
/home/aperson/Projects/ComputerProgramming/C++/OpenGLExample/
It should not be
LIBS += -L /usr/lib/ -llibQtOpenGL.so.4.6.2
but
LIBS += -L /usr/lib/ -lQtOpenGL
Because for the linker -lfoo means libfoo.so (and it should be able to find the right version of the file, so you don't need to tell about 4.6.2)
Probably, you don't even need a special LIBS since opengl is mentioned in the QTline. But you should be sure that the libqt4-opengl-dev package is installed.
Taken from QtOpenGL Module :
The Qt OpenGL module makes it easy to use OpenGL in Qt applications. It provides an OpenGL widget class that can be used just like any other Qt widget, except that it opens an OpenGL display buffer where you can use the OpenGL API to render the contents.
To include the definitions of the module's classes, use the following directive:
#include <QtOpenGL>
To link against the module, add this line to your qmake .pro file:
QT += opengl
You might need to link to your opengl library. This should do :
LIBS += -lGL
It is because you have told qmake that you are creating a console application in your .pro file making it ignore all the GUI libraries. So get rid of the CONFIG += console line.
The project file you have seems OK. QMake should generate the corrent -l -L command for you. IMHO that is not the problem.
Are you missing the opengl/Qt4 package? Its called libqt4-opengl-dev on Ubuntu and Debian.
See
http://packages.debian.org/sid/libqt4-opengl-dev
http://packages.ubuntu.com/search?searchon=names&keywords=libqt4-opengl-dev
Type this on your shell to check and install the package if needed.
$ dpkg -l | grep opengl
ii libqt4-opengl 4:4.8.0-1ubuntu11 Qt 4 OpenGL module
$ aptitude install libqt4-opengl-dev