Link QT 2.3 under win32?

Discussion in 'C++' started by Kevin, Aug 16, 2007.

  1. Kevin

    Kevin Guest

    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!
     
    Kevin, Aug 16, 2007
    #1
    1. Advertising

  2. Kevin

    Jim Langston Guest

    "Kevin" <> wrote in message
    news:...
    > 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.
     
    Jim Langston, Aug 16, 2007
    #2
    1. Advertising

  3. On 2007-08-17 00:30, Kevin wrote:
    > 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.

    --
    Erik Wikström
     
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Aug 17, 2007
    #3
  4. Jim Langston wrote:
    > "Kevin" <> wrote in message...

    [...]
    >> 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.

    --
    Thomas
    http://www.netmeister.org/news/learn2quote.html
     
    Thomas J. Gritzan, Aug 17, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Lyman
    Replies:
    0
    Views:
    710
    Alex Lyman
    Mar 7, 2004
  2. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    955
    Kevin Spencer
    May 17, 2005
  3. Java and Swing
    Replies:
    1
    Views:
    708
    Chris Lambacher
    Oct 24, 2005
  4. Tim Golden
    Replies:
    0
    Views:
    463
    Tim Golden
    Oct 21, 2005
  5. rcmn
    Replies:
    1
    Views:
    377
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
Loading...

Share This Page