Unrecognized Command Line Option '-WI'

11,971

Solution 1

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

Solution 2

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.

Share:
11,971
Nick Corin
Author by

Nick Corin

Polyglot software engineer working primarily with Go.

Updated on June 19, 2022

Comments

  • Nick Corin
    Nick Corin about 2 years

    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
    
  • Nick Corin
    Nick Corin over 10 years
    Well, this is what I found not in the Makefile but in the Makefile.Debug. LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl
  • Mats Petersson
    Mats Petersson over 10 years
    Right, so remove the extra -Wl on the end (but I expect the makefile is generated, so the generator probably has some "empty variable" that it prepends with -Wl.
  • Nick Corin
    Nick Corin over 10 years
    Yeah, the Makefile is generated. And I'm not sure how to sort it out permanently.