Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized Command Line Option '-WI'

Tags:

c++

mingw

qt

I'm trying to set up my Qt for college and I'm running into some issues. I'm running Windows 8, and I'm not sure which version of Qt or QtCreator but not the latest - we were given the version installer so we must use this one, although I did install the latest MinGW myself before the QtCreator setup.

I tried some demo code in QtCreator and I got the error "Unrecognized Command Line Option "-WI" when I try run the following code.

#include <QtCore/QCoreApplication>
#include <QtGui/QMessageBox>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QMessageBox msgBox;
    msgBox.setText("This is some text.");
    msgBox.exec();


    return a.exec();
}

I need to do my assignment and I'm not sure how I can do it when I'm getting all of these strange errors. Any help would be appreciated.

Thanks in advance!

* EDIT *

This is the error output that I can find in QtCreator during the build process.

Running build steps for project TestProject...
Configuration unchanged, skipping qmake step.
Starting: "C:/MinGW/bin/mingw32-make.exe" -w 
mingw32-make: Entering directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop' 
C:/MinGW/bin/mingw32-make -f Makefile.Debug 
mingw32-make[1]: Entering directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop' 
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\TestProject.exe debug/main.o -L"c:\Qt\2010.04\qt\lib" -lQtCored4 
Makefile.Debug:73: recipe for target 'debug\TestProject.exe' failed 
mingw32-make[1]: Leaving directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop' 
Makefile:34: recipe for target 'debug' failed 
mingw32-make: Leaving directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop' 
g++: error: unrecognized command line option '-Wl' 
mingw32-make[1]: *** [debug\TestProject.exe] Error 1 
mingw32-make: *** [debug] Error 2 
The process "C:/MinGW/bin/mingw32-make.exe" exited with code %2.
Error while building project TestProject (target: Desktop)
When executing build step 'Make'

Here are the contents of the .pro file generated by QtCreator :

QT       += core

QT       -= gui

TARGET = TestProject
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp
like image 383
Nick Corin Avatar asked Mar 09 '14 13:03

Nick Corin


2 Answers

As Mats says the problem is the extra -Wl in the command line.

This is due to a bug in the QT conf files, and thankfully this can be fixed "permanently" (locally).

You need to edit one (possibly both) of these files (often in C:\Qt\2010.02\qt\mkspecs):

  • mkspecs\default\qmake.conf
  • mkspecs\win32-g++\qmake.conf

changing this:

QMAKE_LFLAGS        = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl

to this:

QMAKE_LFLAGS        = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads

because somehow the -Wl, from the start of the first line is wrongly on the end of the second line.

After this edit, if you clean and then rebuild your project you will no longer see the error.

Notes:

  • this same bug causes this issue too, so thanks to leemes for his answer there)
  • it is fixed in Qt since version 4.7 I believe
like image 195
sparrowt Avatar answered Oct 16 '22 22:10

sparrowt


The problem is clearly:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\TestProject.exe debug/main.o -L"c:\Qt\2010.04\qt\lib" -lQtCored4

I'm not sure exaclty how this is compiled, but to me it looks like a makefile with -Wl${somestuff} and for some reason ${somestuff} is not defined. Either that, or there is a spurious -Wl in the commendline for the link command, but that seems less likely.

like image 25
Mats Petersson Avatar answered Oct 16 '22 22:10

Mats Petersson