Error building main app



  • Hi All,

    I have a qt project that is combined from 3 diffrent static libs + one app (main)

    all the 3 libs had been build successfully but when trying to build the main app i got the next error:
    ....\Debug\main.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

    This is my .pro file:

    QT += core
    QT -= gui

    CONFIG += c++11

    TARGET = tcpTester
    CONFIG += console
    CONFIG -= app_bundle

    SOURCES += main.cpp
    TcpTesterManagerExecuter.cpp

    HEADERS +=
    TcpTesterManagerExecuter.h

    CONFIG += debug

    TEMPLATE = app
    win32 {
    message(inside win32 tcpTesterApp scope)
    contains(QMAKE_HOST.arch, X86_64) {
    QMAKE_LFLAGS += /MACHINE:X64
    } else {
    QMAKE_LFLAGS += /MACHINE:X86
    QMAKE_CXXFLAGS_DEBUG += /MDd
    QMAKE_CXXFLAGS_RELEASE += /MT
    }

    CONFIG(debug, debug|release){
        DESTDIR = $$_PRO_FILE_PWD_/../Debug
        OBJECTS_DIR = $$_PRO_FILE_PWD_/../Debug
        MOC_DIR = $$_PRO_FILE_PWD_/../Debug
        RCC_DIR = $$_PRO_FILE_PWD_/../Debug
    }
    

    win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../LoggerLib/release/ -lLoggerLib
    else:win32:CONFIG(debug, debug|release):
    LIBS += -L$$OUT_PWD/../../Library/Debug/LoggerLib.dll
    LIBS += -L$$OUT_PWD/../../Library/Debug/NetworkLib.lib
    LIBS += -L$$OUT_PWD/../../Library/Debug/tcpTesterLib.lib

    message(out=$$OUT_PWD)
    message(ppwd=$$PWD)
    INCLUDEPATH += $$PWD/../../TcpComp\3rdParty\log4cxx\log4cxx\src\main\include
    DEPENDPATH += $$PWD/../../TcpComp/3rdParty/log4cxx/log4cxx/projects/Debug
    }

    Any idea what am i missing or doing wrong?

    Thanks,

    nirh



  • This is the full error i get:

    The system cannot find the path specified.
    jom: C:\SivronCode\tcpTester\Debug\tcpTesterApp\Makefile.Debug [....\Debug\tcpTester.exe] Error 1
    jom: C:\SivronCode\tcpTester\Debug\tcpTesterApp\Makefile [debug] Error 2
    17:46:05: The process "C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project tcpTester (kit: Desktop Qt 5.7.0 MSVC2013 64bit)
    When executing step "Make"

    I am lost,

    Please help!!!

    Thanks,

    nirh


  • Lifetime Qt Champion

    Hi,

    Your contains on QMAKE_HOST is likely not doing what you think it does.

    In any case and AFAIK, there's no need for you to set the /MACHINE flag.

    I'm also not sure that the paths you are using are correct.



  • Hi @nirh,

    QMAKE_LFLAGS += /MACHINE:X64

    Here you're telling the linker, and only the linker, to use x64, but the compiler will still be producing whatever your Windows SDK is set to.

    ....\Debug\main.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

    So it appears that:

    • your SDK is set to x86
    • the compiler built your obj files for x86
    • you told the linker to use x64
    • when the linker attempted to link, it saw your objs are x86, not x64 and refused to link.

    As @SGaist said, there's no need for you to set the /MACHINE flag.

    Instead, the best thing to do (at least in my experience) is run vcvarsall.bat to set the desired machine type before running qmake and nmake. Then you don't need any custom compiler handling (for x64 vs x86 at least) in the .pro file at all.

    For example, to build both x86 and x64 versions, you could:

    "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
    mkdir my-x86-build
    cd my-x86-build
    qmake <project-source-dir>
    nmake
    cd ..
    "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
    mkdir my-x64-build
    cd my-x64-build
    qmake <project-source-dir>
    nmake
    cd ..
    

    Cheers.



  • Hi @Paul-Colby ,

    Thanks for your answer, But the compiler doesn't conflictes between the machine type ( you can see that the compiler doesnt produce the exe file - no final linkage for main)
    There is an else in my code and the compiler goes to the else .

    I would appriciate any more help,

    Thanks,

    Nirh



  • @nirh said in Error building main app:

    Thanks for your answer

    You're welcome :)

    But the compiler doesn't conflictes between the machine type

    Actually it does. That's exactly what LNK1112 tells you:

    Linker Tools Error LNK1112
    ...
    module machine type 'type1' conflicts with target machine type 'type2'
    ...
    The object files specified as input were compiled for different computer types.
    ...
    Similarly, if you create one module with the x64 compiler and another module with the x86 compiler, and try to link them, the linker will generate LNK1112.

    @nirh said in Error building main app:

    ( you can see that the compiler doesnt produce the exe file - no final linkage for main)

    That's precisely why the final linkage fails and no exe file is produced.

    There is an else in my code and the compiler goes to the else .

    That's actually not (likely to be) true... I suspect that you think that the win32 scope in *.pro means 32-bit... it doesn't. It means the "win32 API", which Microsoft has since renamed to Windows API. Basically, in old Microsoft parlance:

    • to program 32-bit Windows, you use the win32 API with the x86 target architecture;
    • to program 64-bit Windows, you use the win32 API with the x64 target architecture;

    This all arose because of the way AMD64 was simply an extension to the existing i386 instruction set, and so Microsoft's 64-bit support was (and still is) and extension of win32. You can see how that can be confusing though, so Microsoft has since renamed "win32 API" to "Windows API" to reduce the confusion.

    But what all that means is:

    win32 {
        # This will be included on all Windows builds, including 32-bit, 64-bit, MSVC, MinGW, etc.
    } else {
        # This will be included on all non-Windows builds, such as on Linux, OSX, etc.
    }
    

    So since you're on Windows, qmake will not be using the else branch as you suggest, at least that's how I read it. I'd suggest you add a message call in both branches (you already have something in one) to prove it either way :)

    Cheers.



  • To obtain an if-else in a pro file based on the architecture you can use

        contains(QMAKE_TARGET.arch, x86_64){
           // This is 64 bit
        }
        else{
            // This is 32 bit
        }
    

    This is independent from the operating system you use



  • @Paul-Colby and @VRonin

    Sorry for my miss understood,

    But i dont recieve any LNK1112...

    this is the Error i get: ( WHAT AM I MISSING HERE ? ... I already clean all and Rebuild...)

    The system cannot find the path specified.
    jom: C:\SivronCode\tcpTester\Debug\tcpTesterApp\Makefile.Debug [....\Debug\tcpTester.exe] Error 1
    jom: C:\SivronCode\tcpTester\Debug\tcpTesterApp\Makefile [debug] Error 2
    17:46:05: The process "C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project tcpTester (kit: Desktop Qt 5.7.0 MSVC2013 64bit)
    When executing step "Make"

    Thanks,
    most appriciate your help..

    Nirh


  • Moderators

    @nirh From your first post:
    "all the 3 libs had been build successfully but when trying to build the main app i got the next error:
    ....\Debug\main.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'"

    So, you do receive it.
    Don't forget to rerun qmake after changing pro file.


  • Moderators

    @nirh said in Error building main app:

    The system cannot find the path specified.

    This is not the actual error. What was printed before that line?



  • Hi @jsulm,

    I think i got some advance ...

    I Just open a new and empty project (console ) and i got the next error:

    LNK1104: cannot open file 'kernel32.lib'

    Please note that i compile for win32 using QT,

    This is the empty project .pro file what is missing ?

    QT += core
    QT -= gui

    CONFIG += c++11

    TARGET = test1Hello
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp


  • Moderators

    @nirh You're using MSVC2013 compiler, right? Installed Qt is for MSVC2013 as well? Did you try to build a simple C++ project in MSVC2013?



  • Hi @jsulm,

    It seems that there is something with regarding your answer,
    After checking QT configuration i had found out that:

    This is the QT Version that i use: Qt 5.7.0 MSVC2013 64bit
    The list of compilers Qt detected are:
    1. Microsoft Visual C++ Compiler 10.0 (x86)
    2. Microsoft Visual C++ Compiler 10.0 (amd64)
    3. Microsoft Visual C++ Compiler 10.0 (x86_amd64)
    4. Microsoft Visual C++ Compiler 12.0 (x86)
    5. Microsoft Visual C++ Compiler 12.0 (amd64)
    6. Microsoft Visual C++ Compiler 12.0 (x86_amd64)
    7. Microsoft Visual C++ Compiler 12.0 (x86_arm)
    8. Microsoft Visual C++ Compiler 12.0 (amd64_arm)

    It seems like that the Qt version is higher then the Compilers that Qt Auto-detected!!!!

    Am i correct?

    If so what do you think i should do?

    Thanks,

    nirh



  • If i am compiling the QT examples on windows,

    Should it compiled with no errors, Or should i add anything else to the .pro file?


  • Lifetime Qt Champion

    Don't mix Qt and Qt Creator. They are separated projects.

    You have both VS2010 and VS2013 installed so you should be good to build.

    The examples shouldn't require anything particular to build.

    Did you check that your Kit + Qt version doesn't have any warning/error signaled ?



  • Thanks @SGaist ,

    This is my test1.Hello.pro file:
    QT += core
    QT -= gui

    CONFIG += c++11

    TARGET = test1Hello
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    This are the erros i get when i try to compile an empty console project:

    09:35:13: Running steps for project test1Hello...
    09:35:13: Starting: "C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe" clean
    C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug clean
    del debug\main.obj
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\debug\main.obj
    del debug\test1Hello.exp debug\test1Hello.ilk debug\test1Hello.idb
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\debug\test1Hello.exp
    C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release clean
    del release\main.obj
    del release\test1Hello.exp
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\release\main.obj
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\release\test1Hello.exp
    del test1Hello.exp
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\test1Hello.exp
    del test1Hello.ilk
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\test1Hello.ilk
    del test1Hello.idb
    Could Not Find C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\test1Hello.idb
    09:35:13: The process "C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe" exited normally.
    09:35:13: Configuration unchanged, skipping qmake step.
    09:35:13: Starting: "C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe"
    C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
    cl -c -nologo -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -EHsc /Fddebug\test1Hello.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_CORE_LIB -I..\test1Hello -I. -I....\Qt\Qt5.7.0\5.7\msvc2013_64\include -I....\Qt\Qt5.7.0\5.7\msvc2013_64\include\QtCore -Idebug -I....\Qt\Qt5.7.0\5.7\msvc2013_64\mkspecs\win32-msvc2013 -Fodebug\ @C:\Users\nir\AppData\Local\Temp\main.obj.2724.16.jom
    main.cpp
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture=''" /MANIFEST:embed /OUT:debug\test1Hello.exe @C:\Users\nir\AppData\Local\Temp\test1Hello.exe.2724.702.jom
    LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
    jom: C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\Makefile.Debug [debug\test1Hello.exe] Error 1104
    jom: C:\Temp\build-test1Hello-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\Makefile [debug] Error 2
    09:35:14: The process "C:\Qt\Qt5.7.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project test1Hello (kit: Desktop Qt 5.7.0 MSVC2013 64bit)
    When executing step "Make"
    09:35:14: Elapsed time: 00:01.

    What do i miss or do wrong?

    Thanks,

    nirh


  • Moderators

    @nirh What about the question @SGaist asked: "Did you check that your Kit + Qt version doesn't have any warning/error signaled ?". You did not answer it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.