PDA

View Full Version : How to Include Qwt in My Project



gbmtoday
1st November 2010, 11:47
Hey Guys

I have a project and I want to use qwt_text in it .
So I installed qwt . Now I don't know how to include qwt_text in it:confused:

I mean what are the neccessary changes that I have to make in my .pro file .

I use ubuntu 10.10 , QtCreator 2.0.1 , Qt 4 , Qwt 5.2.1

sry for dumb question:(

cooper
3rd November 2010, 21:07
Hi gbmtoday,

I am new to Qwt too. I am using the same os as yours. I may give you a help.

Can you see the qwt widget in your qt creator? if you can jump to 3)

1) need to copy some files
$ cp /home/czhang/qtsdk-2010.04/qwt-5.2.1/designer/plugins/designer/libqwt_designer_plugin.so /home/czhang/qtsdk-2010.04/bin/designer
$ sudo cp -a /home/czhang/qtsdk-2010.04/qwt-5.2.1/lib/* /usr/lib64

2) run your qt creator, you will see qwt widgets in there.

3) in your .pro file, you need to add:


LIBS += -lqwt
INCLUDEPATH += /home/czhang/qtsdk-2010.05/qwt-5.2.1/src


you may need to add the following lib at the end:


LIBS += -L/usr/local/lib -lQtSvg


I wrote a note to help me to remember what I did. here is the link, i hope it will be helpful.
http://studyard.blogspot.com/2010/10/install-qwt-problem.html

gbmtoday
5th November 2010, 17:11
Thanks Buddy
Nice Blog by the way

Added after 1 38 minutes:

I installed QtCreator and Qt from ubuntu official repository so I don't have a folder named qtsdk-2010.04

also when I try to make my project I face this error

cannot find -lqwt

cooper
7th November 2010, 20:37
I don't have a folder named qtsdk-2010.04

it does not matter.
it might install in different directory. you can use "find"
cz@cz-laptop:~$ find /home/cz -name qtcreator
/home/cz/qtsdk-2010.05/bin/qtcreator
/home/cz/qtsdk-2010.05/lib/qtcreator
/home/cz/qtsdk-2010.05/share/doc/qtcreator
/home/cz/qtsdk-2010.05/share/qtcreator
/home/cz/.config/Nokia/qtcreator

you will see where the qt is installed. In my case, it installed in /home/cz/qtsdk-2010.05/


cannot find -lqwt
you need to give a path where you install the Qwt, eg:


LIBS += -lqwt
INCLUDEPATH += /home/cz/qtsdk-2010.05/qwt-5.2.1/src

Uwe
8th November 2010, 06:44
1) Download qwt-5.2.1.tar.bz2
2) tar xfj qwt-5.2.1.tar.bz2
3) cd qwt-5.2.1
4) qmake
5) make
6) su -c "make install" ( Boys, what's so hard about doing this ? )

Now the designer plugin should be copied into the plugins/designer directory of your Qt install directory. All other files can be found in /usr/local/qwt-5.2.1.

The following steps are Linux or Qt basics:

7) The Qwt designer plugin ( or any application using Qwt ) needs to see the Qwt library. Read about ldconfig or LD_LIBRARY_PATH how to do so. Don't continue before "ldd <your qt directory>/plugins/designer/libqwt_designer_plugin.so" shows a valid path for libqwt.so.

When using LD_LIBRARY_PATH note, that an environment variable is only valid for the process itsself and its child processes. Until you have understood what this means better start the designer/creator manually from the shell, where you have set LD_LIBRARY_PATH.

8) Add the following to your application project file


INCLUDEPATH += /usr/local/qwt-5.2.1/include
LIBS += -L/usr/local/qwt-5.2.1/lib -lqwt

Uwe

HelderC
10th November 2010, 02:05
Thanks Buddy
Nice Blog by the way

Added after 1 38 minutes:

I installed QtCreator and Qt from ubuntu official repository so I don't have a folder named qtsdk-2010.04

also when I try to make my project I face this error

cannot find -lqwt

Install this package too: libqwt5-qt4-dev
When the install will be done. You will see the new Qwt widgets in QtCreator.

imnewtoqt
2nd February 2011, 00:56
Well I've done all of this and I still cant build a simple qwt project in the qtcreator tool.
I can build from the command line using the qmake and make. From the command line the application compiles fine and links to the /usr/local/qwt-5.2.1/lib/libqwt.so libs fine and produces an executable.
From creator it doesn't seem to link with lqwt.
The project source is the simple.cpp of the examples and the simple.pro file is as follows
TARGET = simple

SOURCES = \
simple.cpp


INCLUDEPATH += /usr/local/qwt-5.2.1/include
LIBS += -L/usr/local/qwt-5.2.1/lib -lqwt



The /usr/lib/qtcreator/plugins dir contains the libqwtplugin.so lib
and running ldd gives
linux-gate.so.1 => (0x00911000)
libqwt.so.5 => /usr/local/qwt-5.2.1/lib/libqwt.so.5 (0x00e1d000)
...

The creator compiler output is as follows
Running build steps for project simple_plot...
Configuration unchanged, skipping qmake step.
Starting: "/usr/bin/make" -w
make: Entering directory `/home/ps/Downloads/qwt521/qwt-5.2.1/examples/simple_plot-build-desktop'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I/home/ps/qttest/PlotExamples/Plot -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/local/qwt-5.2.1/include -I. -I/home/ps/qttest/PlotExamples/Plot -I. -o simple.o /home/ps/qttest/PlotExamples/Plot/simple.cpp
g++ -o simple simple.o -L/usr/lib -L/usr/local/qwt-5.2.1/lib -lqwt -lQtGui -lQtCore -lpthread
simple.o: In function `Plot':
/home/ps/qttest/PlotExamples/Plot/simple.cpp:64: undefined reference to `QwtPlot::QwtPlot(QWidget*)'

plus a about 100 other undefined references to the qwt methods


Thanks in advance for any help

Uwe
2nd February 2011, 07:31
I can build from the command line using the qmake and make. From the command line the application compiles fine and links to the /usr/local/qwt-5.2.1/lib/libqwt.so libs fine and produces an executable.

From creator it doesn't seem to link with lqwt.

g++ -o simple simple.o -L/usr/lib -L/usr/local/qwt-5.2.1/lib -lqwt -lQtGui -lQtCore -lpthread

Simply compare the compiler/linker commands with the successful ones you get from qmake on the console.

Maybe disable the Shadow Build option in the Creator, so that the compile/linker commands are closer to your other build.

Uwe

imnewtoqt
3rd February 2011, 01:13
Simply compare the compiler/linker commands with the successful ones you get from qmake on the console.

Maybe disable the Shadow Build option in the Creator, so that the compile/linker commands are closer to your other build.

Uwe

OK thanks very good idea.
The result is painful and bizzar :


g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I/usr/local/qwt-5.2.1/include -I/usr/include/qt3 -o simple.o simple.cpp
g++ -o simple simple.o -L/usr/share/qt3/lib -L/usr/X11R6/lib -L/usr/local/qwt-5.2.1/lib -lqwt -lqt-mt -lXext -lX11 -lm -lpthread

So it seems that on the command line I'm linking against qt3. This can't be good.
I think i'll uninstall and reinstall everything I can.
Thanks again

Added after 1 35 minutes:

Thankyou Uwe
uninstalling the qt3 dev tools and reinstall the qt4 dev tools and reinstalling qwt521
seems to have fixed everything. And it only took 1 hour 35 min to do and test.