tags:

views:

6551

answers:

5

I have a stub Qt application and I keep getting compiler errors

#include <QApplication>

int main(int argc, char *argv[])
 {
     return 0;
 }

I used qmake -project and qmake commands and as far as I can tell they did their job correctly. When I subsequently call make at the command line I get the following error:

g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
-DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I
'../../../../qt/include/QtCore' -I'../../../../qt/include/QtCore' -I'../../../..
/qt/include/QtGui' -I'../../../../qt/include/QtGui' -I'../../../../qt/include' -
I'.' -I'c:/qt/include/ActiveQt' -I'release' -I'.' -I'../../../../qt/mkspecs/defa
ult' -o release/Main.o Main.cpp
cc1plus.exe: Invalid option 'threads'
make[1]: *** [release/Main.o] Error 1
make: *** [release] Error 2

My searches on Google tell me that threading is important to keep but not how to fix this error. Any help will be appreciated.

A: 

I now get

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel oc 
-Wl,-s -pthread -Wl -Wl,-subsystem,windows -o release/raytrace.exe 
object_scr ipt.raytrace.Release  -L'c:/qt/lib' -lmingw32 -lqtmain -lQtGui -lgdi32 
-lcomdlg3 2 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 
-luser32 - lshell32 -luuid -lole32 -ladvapi32 -lws2_32 
g++: unrecognized option `-pthread' 
/cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/bin/ld: cannot open -lmsimg32: 
No such file or directory collect2: 
ld returned 1 exit status make[1]: *** 
[release/raytrace.exe] Error 1 make: *** [release] Error 2
Edit your original question. Replying to your own question means I am now lost and don't know what to read first or last.
Max Howell
A: 

Based on the later response from the questioner, not the original question.

From the MSYS prompt run "ls /mingw/lib/libmsimg32.a" and see if you have that file. My installation does (MinGW GCC 3.4.5). If you have that file you may need to add -L/mingw/lib. If you don't have the file you may have missed installing the windows api part of MinGW.

Either way remove -pthread. You're using the Win32 api.

If this doesn't work you need to specify which version of MinGW you're using and, if you're using MSYS, which version of MSYS.

Adam Mitz
+2  A: 

Well I had similar problem before when I was installing MingW downloaded from the web, but in the other hand while installing Qt it will ask you to download the version of MingW which is compatible with Qt. So have you tried installing it when the Qt installer asked you?

milot
Qt installer? I could only find source packages...
Yeah, use the MinGW 3.4.2. I run into troubles as well trying 5.x versions.
Tuminoid
+2  A: 

++milot

I only use MinGW to compile Qt on Windows and that's the easiest way to make sure you have everything you need.

Here is the link for the Open Source Qt version: http://trolltech.com/downloads/opensource/appdev/windows-cpp

Use the "Or download Qt with the MinGW compiler included: Size: 149,3 Mb" link.

The other way to use MinGW is to compile Qt with MinGW and then compile your application, but it depends on if you're compiling in MSYS or just using MinGW.

Chris Roland
+1  A: 

Qt 4.5 has Qt Creator 1.1 which is easy to develop applications.

Designing and coding is combined in Qt Creator and mucy easier to use.

you can experience it like using VB IDE(or rather like eclipse,netbeans,etc.)

when run the app. the project is compiled in either in debug or release mode.