Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ㅠ0ㅠ help me plz..



  • hi~ guys

    i want to compile 'hello world' tutorial source..

    @
    #include <QApplication>

    #include <QPushButton>

    #include <QTranslator>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QTranslator translator;

    translator.load("hellotr_la");
    
    app.installTranslator(&translator);
    
    QPushButton hello(QPushButton::tr("Hello world!"));
    
    hello.resize(100, 30);
    
    hello.show();
    
    return app.exec&#40;&#41;;
    

    }
    @

    but... linking fail..

    Would you tell me what's the problem? plz..

    17:16:27 **** Incremental Build of configuration Debug for project test ****
    make all
    'Building target: test.exe'
    'Invoking: MinGW C++ Linker'
    g++ -L"C:\Qt\4.8.4\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -mthreads -Wl,-subsystem,windows -o "test.exe" ./test.o
    ./test.o: In function main': C:\Project\test\Debug/../test.cpp:6: multiple definition ofmain'
    c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o):C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:24: first defined here
    C:\Qt\4.8.4\lib/libqtmaind.a(qtmain_win.o): In function WinMain@16': c:\iwmake\build_mingw_opensource\src\winmain/qtmain_win.cpp:131: undefined reference toqMain(int, char**)'
    ./test.o:test.cpp:(.text+0x33): undefined reference to _imp___ZN12QApplicationC1ERiPPci' ./test.o:test.cpp:(.text+0x48): undefined reference to_imp___ZN11QTranslatorC1EP7QObject'
    ./test.o:test.cpp:(.text+0xa5): undefined reference to _imp___ZN11QTranslator4loadERK7QStringS2_S2_S2_' ./test.o:test.cpp:(.text+0xde): undefined reference to_imp___ZN16QCoreApplication17installTranslatorEP11QTranslator'
    ./test.o:test.cpp:(.text+0x118): undefined reference to _imp___ZN11QPushButtonC1ERK7QStringP7QWidget' ./test.o:test.cpp:(.text+0x150): undefined reference to_imp___ZN12QApplication4execEv'
    ./test.o:test.cpp:(.text+0x15f): undefined reference to _imp___ZN11QPushButtonD1Ev' ./test.o:test.cpp:(.text+0x16c): undefined reference to_imp___ZN11QTranslatorD1Ev'
    ./test.o:test.cpp:(.text+0x179): undefined reference to _imp___ZN12QApplicationD1Ev' ./test.o:test.cpp:(.text+0x1df): undefined reference to_imp___ZN11QPushButtonD1Ev'
    ./test.o:test.cpp:(.text+0x1f0): undefined reference to _imp___ZN11QTranslatorD1Ev' ./test.o:test.cpp:(.text+0x201): undefined reference to_imp___ZN12QApplicationD1Ev'
    ./test.o:test.cpp:(.text$_ZN7QStringC1EPKc[QString::QString(char const*)]+0x15): undefined reference to _imp___ZN7QString16fromAscii_helperEPKci' ./test.o:test.cpp:(.text$_ZN7QStringC1Ev[QString::QString()]+0xb): undefined reference to_imp___ZN7QString11shared_nullE'
    ./test.o:test.cpp:(.text$_ZN7QWidget6resizeEii[QWidget::resize(int, int)]+0x2d): undefined reference to _imp___ZN7QWidget6resizeERK5QSize' ./test.o:test.cpp:(.text$_ZN11QPushButton2trEPKcS1_[QPushButton::tr(char const*, char const*)]+0x19): undefined reference to_imp___ZN11QPushButton16staticMetaObjectE'
    ./test.o:test.cpp:(.text$ZN11QPushButton2trEPKcS1[QPushButton::tr(char const*, char const*)]+0x25): undefined reference to `imp___ZNK11QMetaObject2trEPKcS1'
    collect2: ld returned 1 exit status
    make: *** [test.exe] Error 1

    17:16:27 Build Finished (took 320ms)

    [[Added markups for code, Tobias]]



  • Hi,

    Did you try add to *.pro file module with name "widgets" something like this:
    @
    QT += widgets
    @


  • Moderators

    [quote author="shav" date="1358608747"]Hi,

    Did you try add to *.pro file module with name "widgets" something like this:
    @
    QT += widgets
    @[/quote]

    He is using Qt 4, there is no module called "widgets" there.

    wow505 please attach your .pro file, too.


Log in to reply