You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, August 4th 2009, 5:57pm

[SOLVED] Qwt link problem with MSVS2008

Hi,

I recently took up learning Qt and it's not going as well as I'd hoped :(.
I use Microsoft Visual Studio 2008 Pro along with Qt 4.5.2 x64 (compiled myself with "configure -platform win32-msvc2008" and nmake).
I set appropriate evironment variables ( QTDIR points to c:\development\x64\qt, where I compiled Qt). I also installed the VSaddin 1.0.2.

Qt itself works (for as far as I can see). I have gotten to chapter 2 of "QT GUI programming in C++, 1st edition", and both sample programs compile fine and run as they should.

I recently compiled Qwt 5.2.0 succesfully, as I have a debug and release .lib and .dll and some other files. (I compiled it from the x64 win64 command prompt with "qmake qwt.pro" and nmake)

Then I tried to create a new solution in VS with all examples from Qwt (to learn how it works). I have one project in the solution, also the first Qwt example, "bode". I created a new Qt Application, deleted all automatically generated files, copied the example source code to de project directory and added them in VS. This also places some moc_*.cpp files in the project.
I think I have linked Qwt correctly:
bode->properties->linker->general->additional library directories-> c:\development\x64\qwt\lib
->input->additional dependencies->qwtd5.lib (debug library for a debug project, in the release config I added qwt5.lib)
The directory is correct and the location of the qwt libraries built previously. I also set the appropriate include directories so Visual Studio can locate the header files (the error is not here)

When I compile the project, I get an error:
1>moc_bode_plot.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlot::staticMetaObject" (?staticMetaObject@QwtPlot@@2UQMetaObject@@B)
1>C:\Users\Ruben\Documents\Visual Studio 2008\Projects\Qwt Examples\Debug\bode.exe : fatal error LNK1120: 1 unresolved externals

I can make it compile if I comment out the Q_OBJECT macro's, but then none of the connections work (obviously). The weird thing is that the program described in chapter 2 of the aforementioned book (which also uses Q_OBJECT), work fine.

Please help. If you need any more info, feel free to ask. Thanks!

This post has been edited 2 times, last edit by "rubenvb" (Aug 6th 2009, 11:09am)


2

Tuesday, August 4th 2009, 6:24pm

I found it!!

First of all, I am sorry to post an answer to my own thread so quickly,
second of all, here's the solution I have been searching for all day:

- RTFM, translated: read the <peep> documentation of everything you use
- in order to use Qwt as a dll, the project need a preprocessor define (configuration properties->c/c++->preprocessor->preprocessor definitions-> QWT_DLL (and leave the rest as it is)

This, along with above configuration, removes all linker errors. I hope this may help somebody in the future.

3

Sunday, September 13th 2009, 11:15pm

Thank you.

Thank you. You saved me. I registered to say thanks to you.
Bests.

4

Monday, October 26th 2009, 3:28pm

First of all, I am sorry to post an answer to my own thread so quickly,
second of all, here's the solution I have been searching for all day:

- RTFM, translated: read the <peep> documentation of everything you use
- in order to use Qwt as a dll, the project need a preprocessor define (configuration properties->c/c++->preprocessor->preprocessor definitions-> QWT_DLL (and leave the rest as it is)

This, along with above configuration, removes all linker errors. I hope this may help somebody in the future.
Thank you. You saved me. I registered to say thanks to you.
Bests.
I'm sorry to dig up this thread, but I was looking for a solution to this problem for few hours now.
I signed up to say thanks. You probably saved me a few more ours of searching!

5

Tuesday, November 17th 2009, 3:00pm

Thank you...but..

Hi friend,

Thank you for your hint... atm, I m facing the same problem.

As you suggested, I added the QWT_DLL flag in while compiling the qwt source code and created the libraries successfully.

Now am trying use the QwtPlot as a base class to one of my classes in the appliction, it complained the same problem.

Source code

1
error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlot::staticMetaObject"


Now I did add the QWT_DLL to my application compiler flags to too.

Now after adding the above flag and compile the application, the problem is still exists. :(

Please help