PDA

View Full Version : Configure dev-c++ with QT



iGoo
26th May 2006, 06:55
I install dev-c++ and then "QT open source with mingw".
And,I select dev-cpp/bin as mingw directory in first step of the installation of QT.
All goes ok.

I add the qt/lib qt/include dirs to dev-cpp's compiler option.
When I build the code snippet below.Link error.

#include<QtGui/QApplication>
#include<QtGui/QPushButton>
int main(int argc,char* argv[])
{
QApplication app(argc,argv);
//QPushButton hello("Hello World");
//hello.resize(100,300);
//hello.show();
return app.exec();
}

errors:

[Linker error] undefined reference to `_imp___ZN12QApplicationC1ERiPPc'
[Linker error] undefined reference to `_imp___ZN12QApplication4execEv'
[Linker error] undefined reference to `QApplication::~QApplication()'
[Linker error] undefined reference to `QApplication::~QApplication()'
ld returned 1 exit status

build logs:

Compiler: Default compiler
Executing mingw32-g++.exe...
mingw32-g++.exe "M:\实验\qtHello.cpp" -o "M:\实验\qtHello.exe" -I"M:\dev_tool\Dev-Cpp\include\c++" -I"M:\dev_tool\QT4\include" -L"M:\dev_tool\QT4\lib" -L"M:\dev_tool\Dev-Cpp\lib"
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccwRaaaa.o(.text+0x171):qtHello.cpp: undefined reference to `_imp___ZN12QApplicationC1ERiPPc'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccwRaaaa.o(.text+0x17f):qtHello.cpp: undefined reference to `_imp___ZN12QApplication4execEv'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccwRaaaa.o(.text+0x19d):qtHello.cpp: undefined reference to `QApplication::~QApplication()'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccwRaaaa.o(.text+0x1c6):qtHello.cpp: undefined reference to `QApplication::~QApplication()'
collect2: ld returned 1 exit status

Execution terminated



Thanks

munna
26th May 2006, 08:14
try

#include<QApplication>
#include<QPushButton>

jacek
26th May 2006, 10:41
mingw32-g++.exe "M:\实验\qtHello.cpp" -o "M:\实验\qtHello.exe" -I"M:\dev_tool\Dev-Cpp\include\c++" -I"M:\dev_tool\QT4\include" -L"M:\dev_tool\QT4\lib" -L"M:\dev_tool\Dev-Cpp\lib"
You didn't link your application with Qt libraries. Search the forum --- there were some threads about Dev C++.

incapacitant
26th May 2006, 16:52
Dev-C++ requires class browsing desactivated and
in Project->Project Options->Makefile->Use Custom Makefile

The makefile you generate from your .pro with Qt qmake :
qmake -project // to generate the .pro
qmake // to generate the custom makefile
and then point to this makefile

fullmetalcoder
29th May 2006, 09:18
Custom makefile didn't worked for me! Looks like build targets are not the same...

incapacitant
29th May 2006, 13:57
I compiled your application with Dev-Cpp and it works fine so it is the configuration.

1. did you generate the custom makefile :
in that directory qmake - project, qmake

2. mak sure you compile within Dec-Cpp with this custom makefile

3. do you have the environment variables correctly set up in configuration panel :
PATH: C:\Qt\4.1.3\bin;C:\MinGW\bin
QMAKESPEC: win32-g++
QTDIR: C:\Qt\4.1.3

fullmetalcoder
31st May 2006, 12:09
I've given up Dev-Cpp a long time ago...
I now use command prompt to compile and my own text editor to do the rest :D