Link QT 2.3 under win32?

K

Kevin

Hi guys,
I am a beginner for QT, and I installed the free qt 2.3 under windows
(XP), as well as the MS's free VC expression edition (for their
compilers, linkers, etc), and the SDK tool.

My first qt program is simple: the first demo which comes with the qt
2.3 installation. The only one code file is: main.cpp, and it is:

#include <qapplication.h>
#include <qpushbutton.h>

int main( int argc, char **argv )
{
QApplication a( argc, argv );

QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );

a.setMainWidget( &hello );
hello.show();
return a.exec();
}

Then I try to compile and link it, using:

cl -c -nologo -I%QTDIR%/include -Fmain.obj main.cpp

link /NOLOGO /SUBSYSTEM:windows /OUT:main main.obj %QTDIR%/lib/qt-
mt230nc.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib imm32.lib
winmm.lib wsock32.lib

Now, here comes the error message:

== for the cl, it says ================

main.cpp
c:\qt\2.3\include\qcstring.h(93) : warning C4996: 'strcpy' was
declared deprecated
c:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE
\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider
using strcpy_s instead. To disable deprecation, use
_CRT_SECURE_NO_DEPRECATE. See online help for details.'
c:\qt\2.3\include\qcstring.h(96) : warning C4996: 'strcpy' was
declared deprecated
c:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE
\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider
using strcpy_s instead. To disable deprecation, use
_CRT_SECURE_NO_DEPRECATE. See online help for details.'

But it looks ok since these are just warnings, right?

====== then I try to link it, with these errors =======

main.obj : error LNK2019: unresolved external symbol "private: static
struct QStringData * QString::shared_null" (?
shared_null@QString@@0PAUQStringData@@A) referenced in function
"public: __thiscall QString::~QString(void)" (??1QString@@QAE@XZ)
LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol
_WinMain@16 referenced in function ___tmainCRTStartup
main : fatal error LNK1120: 2 unresolved externals

==================

Any ideas of the link error?

Thanks a lot!
 
J

Jim Langston

Kevin said:
Hi guys,
I am a beginner for QT, and I installed the free qt 2.3 under windows
(XP), as well as the MS's free VC expression edition (for their
compilers, linkers, etc), and the SDK tool.

My first qt program is simple: the first demo which comes with the qt
2.3 installation. The only one code file is: main.cpp, and it is:

#include <qapplication.h>
#include <qpushbutton.h>

int main( int argc, char **argv )
{
QApplication a( argc, argv );

QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );

a.setMainWidget( &hello );
hello.show();
return a.exec();
}

Then I try to compile and link it, using:

cl -c -nologo -I%QTDIR%/include -Fmain.obj main.cpp

link /NOLOGO /SUBSYSTEM:windows /OUT:main main.obj %QTDIR%/lib/qt-
mt230nc.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib imm32.lib
winmm.lib wsock32.lib

Now, here comes the error message:

== for the cl, it says ================

main.cpp
c:\qt\2.3\include\qcstring.h(93) : warning C4996: 'strcpy' was
declared deprecated
c:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE
\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider
using strcpy_s instead. To disable deprecation, use
_CRT_SECURE_NO_DEPRECATE. See online help for details.'
c:\qt\2.3\include\qcstring.h(96) : warning C4996: 'strcpy' was
declared deprecated
c:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE
\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider
using strcpy_s instead. To disable deprecation, use
_CRT_SECURE_NO_DEPRECATE. See online help for details.'

But it looks ok since these are just warnings, right?

====== then I try to link it, with these errors =======

main.obj : error LNK2019: unresolved external symbol "private: static
struct QStringData * QString::shared_null" (?
shared_null@QString@@0PAUQStringData@@A) referenced in function
"public: __thiscall QString::~QString(void)" (??1QString@@QAE@XZ)
LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol
_WinMain@16 referenced in function ___tmainCRTStartup
main : fatal error LNK1120: 2 unresolved externals

==================

Any ideas of the link error?

Thanks a lot!

strcpy has been depreciated by Microsoft, not by anyone else. Those
warnings can be ignored

As for the link error, that is becuase you made a windows applicaiton. You
should of made a console applicaiton.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi guys,
I am a beginner for QT, and I installed the free qt 2.3 under windows
(XP), as well as the MS's free VC expression edition (for their
compilers, linkers, etc), and the SDK tool.

Sorry, can't help you with that. For help with with QT ask in a group
discussing Qt, look at their homepage for more info, also
www.qtforum.org/ is quite good.

Should you post you question there they'll probably ask you the same
ting I'm asking you, why Qt 2.3? It's 8 revisions old, of which two were
major. The latest version of Qt is 4.3, if you don't like that one at
least use Qt 3.
 
T

Thomas J. Gritzan

Jim said:
I am a beginner for QT, and I installed the free qt 2.3 under windows
(XP), as well as the MS's free VC expression edition (for their
compilers, linkers, etc), and the SDK tool.
[...]

As for the link error, that is becuase you made a windows applicaiton. You
should of made a console applicaiton.

He wanted to make a windows application. He is using QT. So changing it
into a console application wouldn't help.

The problem is, that VC++ uses another entry point instead main() for a
Windows application as default. You can change this entry point to using
the main() function by some linker options. The OP can ask on a QT, VC++ or
Windows programming newsgroup on how to do that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top