Saturday, July 5th 2008, 2:28pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. 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

Sunday, January 13th 2008, 3:50pm

Qt4 with Visual Studio 2005 link error

Hi
I am a beginner to Qt, and just installed Qt4 with Visual Studio 2005.
I coded the first example "Hello Qt", then I got the link error when building the project:
Main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) referenced in function _main

I have installed Qt4 and compiled it without any problem. The libraries are in c:\qt\4.3.3\lib, and I have added this path in Visual Studio.

ps: there is no such error when I build the project in the command line like this:
qmake -project
qmake
nmake

Any suggestion is appreciated.
  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

2

Sunday, January 13th 2008, 4:17pm

RE: Qt4 with Visual Studio 2005 link error

Generate msvc project with qmake and use it. "qmake -t vcapp"
Or you need to add QtCore4.lib to project linker options. qmake handles paths and stuff.
Fighting fire with fire.
  • Go to the top of the page

3

Sunday, January 13th 2008, 4:27pm

RE: Qt4 with Visual Studio 2005 link error

Quoted

Originally posted by Messenger
Generate msvc project with qmake and use it. "qmake -t vcapp"
Or you need to add QtCore4.lib to project linker options. qmake handles paths and stuff.


I am sorry I am not quite sure about "Or you need to add QtCore4.lib to project linker options". How to do that in vs2005?
Does this mean I have to do the same thing if I make another project?
  • Go to the top of the page

4

Tuesday, January 15th 2008, 4:49pm

RE: Qt4 with Visual Studio 2005 link error

Quoted

Originally posted by Messenger
Generate msvc project with qmake and use it. "qmake -t vcapp"
Or you need to add QtCore4.lib to project linker options. qmake handles paths and stuff.

Hi:

I found it.
Add QtCore4.lib in Properties->Configuration Properties->Linker->Input->Additional Depencies, right?

But this seems to be project specific. Is there a common place to specify the libraries?
Why cannot VS 2005 find the libraries even I have specified the $(QTDIR)\lib in its lib dir?

Thank you very much.
  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

5

Tuesday, January 15th 2008, 8:06pm

RE: Qt4 with Visual Studio 2005 link error

Because linker (manager) cannot link everything on the path. Imagine the helluva of time it would take until linking ends and functions naming superhell. It is just like a case as with headers. Also you need add other libraries QtGui4.lib (looks like QApplication is here) and etc.
BTW "qmake -t vcapp" generated solution is far better, because in this case you get qtmain.lib inside project (or not?). And in qtmain.lib (the real main entry for QT programs) some initialization is done. See src\winmain\qtmain_win.cpp. Also generates scripts/commands to call uic.exe and moc.exe if required from MSVC. The only drawback is that each time you modify project (the situation when name.pro needs to be processed by qmake) you need manually regenerate msvc project.
Mind that I am no guru of MSVC.
Fighting fire with fire.
  • Go to the top of the page

6

Thursday, January 17th 2008, 1:20pm

RE: Qt4 with Visual Studio 2005 link error

Quoted

Originally posted by Messenger
Because linker (manager) cannot link everything on the path. Imagine the helluva of time it would take until linking ends and functions naming superhell. It is just like a case as with headers. Also you need add other libraries QtGui4.lib (looks like QApplication is here) and etc.
BTW "qmake -t vcapp" generated solution is far better, because in this case you get qtmain.lib inside project (or not?). And in qtmain.lib (the real main entry for QT programs) some initialization is done. See src\winmain\qtmain_win.cpp. Also generates scripts/commands to call uic.exe and moc.exe if required from MSVC. The only drawback is that each time you modify project (the situation when name.pro needs to be processed by qmake) you need manually regenerate msvc project.
Mind that I am no guru of MSVC.


Thanks a lot for your help.
  • Go to the top of the page

kenobe

Beginner

Posts: 6

Location: Singapore

7

Sunday, January 20th 2008, 2:08am

RE: Qt4 with Visual Studio 2005 link error

Hi googling
I have problems building qt4 lib for vc++.net 2005
I am using the Opensource edition.

Are you using the Commercial edition?

If you are using the Opensource editon, could you pls send me the steps of how to build the qt4 lib?

I have tried many times following the steps spelled out from Trolltech.
all that do not work.

Thank you very much
  • Go to the top of the page

CrackedMind

Beginner

Posts: 34

Location: Russia

Occupation: just programmer

8

Sunday, January 20th 2008, 9:10am

1. run Visual Studio 2005 Command Promt
2. cd c:\Qt\4.x.x
3. set QMAKESPEC=win32-msvc2005
4. configure

that's all :)

p.s. tested on Qt 4.3.3
So you can code punk?
  • Go to the top of the page

kenobe

Beginner

Posts: 6

Location: Singapore

9

Monday, January 21st 2008, 5:00am

Hi crackedMind

is your qt4.x.x a commercial editon or opensource edition ?
  • Go to the top of the page

CrackedMind

Beginner

Posts: 34

Location: Russia

Occupation: just programmer

10

Monday, January 21st 2008, 6:52am

open source and Visual C++ 2008 Express Edition
So you can code punk?
  • Go to the top of the page

11

Tuesday, January 22nd 2008, 6:38am

RE: Qt4 with Visual Studio 2005 link error

Quoted

Originally posted by kenobe
Hi googling
I have problems building qt4 lib for vc++.net 2005
I am using the Opensource edition.

Are you using the Commercial edition?

If you are using the Opensource editon, could you pls send me the steps of how to build the qt4 lib?

I have tried many times following the steps spelled out from Trolltech.
all that do not work.

Thank you very much

Hi
I am using commercial version.
Could you post the error message?
  • Go to the top of the page

macabre13

Trainee

Posts: 127

Location: Poland/ Wroclaw

Occupation: sw developer

12

Tuesday, January 22nd 2008, 7:43am

RE: Qt4 with Visual Studio 2005 link error

Quoted

Originally posted by googling

Quoted

Originally posted by Messenger
Generate msvc project with qmake and use it. "qmake -t vcapp"
Or you need to add QtCore4.lib to project linker options. qmake handles paths and stuff.

Hi:

I found it.
Add QtCore4.lib in Properties->Configuration Properties->Linker->Input->Additional Depencies, right?

But this seems to be project specific. Is there a common place to specify the libraries?
Why cannot VS 2005 find the libraries even I have specified the $(QTDIR)\lib in its lib dir?

Thank you very much.


Libs are project specific, because every project have different libs dependency.
- ebm - noise - industrial -
I always could be wrong.
Lets share knowledge!
  • Go to the top of the page

laser2008

Beginner

Posts: 1

Location: Rockville, MD

Occupation: Software Engineer

13

Friday, February 8th 2008, 5:06pm

RE: Qt4 with Visual Studio 2005 link error

in the VS2005 IDE,
1. go to menu "Tools-->Options", expand "Projects and Solutions", click "VC++ Directories".
2. Select "Library files" under "Show directories for".
3. Add "C:\Qt\4.3.3\lib" at the end of library lists.

In this way, VS2005 will automatically link the qt library file for all projects.

This post has been edited 1 times, last edit by "laser2008" (Feb 8th 2008, 5:11pm)

  • Go to the top of the page

Style

Beginner

14

Monday, March 24th 2008, 4:21pm

Doesnt work for me

CrackedMind yor thing did not any changes to my problem :S i dont even have QtCore.lib
where i get all .lib files :S
  • Go to the top of the page

Rate this thread