Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

MSVC fatal error LNK1181: cannot open input file



  • Hello there,
    I am using Qt Creator with Qt 5.13.0 and MSVC 2017 x64. The debug build for my application works just fine. I have switched to release build just not and was unable to compile because of:

    LINK : fatal error LNK1181: cannot open input file 'release\C:_storage_repo_bergen_MDE-Clients_ntm_client_Uslider_qml.obj'
    

    My .pro file looks like this:

    # The application version
    VERSION = 1.0
    
    OTHER_FILES += app.rc
    RC_FILE = app.rc
    
    QT += quick widgets core xml multimedia opcua
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS APP_VERSION=\\\"$$VERSION\\\"
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    
    # disables all the APIs deprecated before Qt 6.0.0
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
    
    HEADERS += \
        ccolumns.h \
        cdataentry.h \
    	cdatastatus.h \
        cdimmode.h \
        cexecutable.h \
        cfleetmanager.h \
        cintegrator.h \
        cnodeextractor.h \
        cnodetype.h \
        criskdata.h \
        crisklevel.h \
        criskname.h \
        criskstate.h \
        cscreenview.h \
        csettings.h \
        cthreadmover.h \
        cuaproxy.h \
    	copcuahelper.h \
        cvartablemodel.h \
        cvessel.h \
        domitem.h \
        dommodel.h
    
    SOURCES += \
        cdataentry.cpp \
        cexecutable.cpp \
        cfleetmanager.cpp \
        cintegrator.cpp \
        cnodeextractor.cpp \
        csettings.cpp \
        cthreadmover.cpp \
        cvartablemodel.cpp \
        cvessel.cpp \
        domitem.cpp \
        dommodel.cpp \
            main.cpp \
        criskdata.cpp \
        cuaproxy.cpp \
    	copcuahelper.cpp
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    DISTFILES +=
    

    I was wondering what could be the case in here. I would appreciate all help.


  • Lifetime Qt Champion

    @Bremenpl said in MSVC fatal error LNK1181: cannot open input file:

    release\C:_storage_repo_bergen_MDE-Clients_ntm_client_Uslider_qml.obj

    Is this really the path you get in the error message?



  • @jsulm yes, I have no idea how was it constructed.



  • @jsulm Looking at the Makefile, it does create this bizzare path'es only for release build:

    SOURCES       = ..\ntm_client\cdataentry.cpp \
    		..\ntm_client\cexecutable.cpp \
    		..\ntm_client\cfleetmanager.cpp \
    		..\ntm_client\cintegrator.cpp \
    		..\ntm_client\cnodeextractor.cpp \
    		..\ntm_client\csettings.cpp \
    		..\ntm_client\cthreadmover.cpp \
    		..\ntm_client\cvartablemodel.cpp \
    		..\ntm_client\cvessel.cpp \
    		..\ntm_client\domitem.cpp \
    		..\ntm_client\dommodel.cpp \
    		..\ntm_client\main.cpp \
    		..\ntm_client\criskdata.cpp \
    		..\ntm_client\cuaproxy.cpp \
    		..\ntm_client\copcuahelper.cpp release\qrc_qml_qmlcache.cpp \
    		release\C:_storage_repo_bergen_MDE-Clients_ntm_client_Uslider_qml.cpp \
    		release\C:_storage_repo_bergen_MDE-Clients_ntm_client_Utopbar_qml.cpp \
    		release\C:_storage_repo_bergen_MDE-Clients_ntm_client_UcontrolButton_qml.cpp \
    

  • Lifetime Qt Champion

    @Bremenpl Really strange. Try to delete the *.pro.user file, delete build directory, run qmake and build.



  • @jsulm Its the same. Qmake creates makesfiles in a different way for the Debug and Release builds.

    This is the qmake call for the debug build:

    C:\Qt\5.13.0\msvc2017_64\bin\qmake.exe C:\storage\repo\bergen\MDE-Clients\ntm_client\ntm_client.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug" && C:/Qt/Tools/QtCreator/bin/jom.exe qmake_all
    

    And this one is for release:

    C:\Qt\5.13.0\msvc2017_64\bin\qmake.exe C:\storage\repo\bergen\MDE-Clients\ntm_client\ntm_client.pro -spec win32-msvc "CONFIG+=qtquickcompiler" && C:/Qt/Tools/QtCreator/bin/jom.exe qmake_all
    


  • @jsulm Ok, disabling the Qt Quick Compiler solved the problem. What does it do anyways? Its disabled in the Debug build. Does it attempts to compile the QML code so the QML files are not needed?


  • Lifetime Qt Champion

    @Bremenpl See https://doc.qt.io/QtQuickCompiler/
    Not sure why it breaks the build. Maybe you have to do something in your pro file to use it properly (I never used it, so don't know).


  • Moderators

    @Bremenpl said in MSVC fatal error LNK1181: cannot open input file:

    @jsulm Ok, disabling the Qt Quick Compiler solved the problem. What does it do anyways? Its disabled in the Debug build. Does it attempts to compile the QML code so the QML files are not needed?

    It indeed takes your qml files, precompiles them to usable binary. In end effect makes the startup process of your application much faster, as the interpreter does not have to parse your QML files before each start.

    I'm using it all the time, and have had never this problem.

    Can you check if the problem persists, if you define a specific directory for the generated files inside your *pro file ?
    using:

    OBJECTS_DIR 
    MOC_DIR 
    RCC_DIR 
    UI_DIR 
    QMLCACHE_DIR
    


  • @jsulm Ok, I thought I was missing qtquickcompiler in the pro file CONFIG section but that did not change anything... On linux side using GCC everything works without unckecing the qt quick compiler, maybe its a windows only thing.



  • @J.Hilk Which DIR(s) should I set exactly?


  • Moderators

    @Bremenpl since it's the *.obj files that make the problems, OBJECTS_DIR ?

    but the quick compiler generated files fall in the QMLCACHE_DIR category



  • @J.Hilk said in MSVC fatal error LNK1181: cannot open input file:

    @Bremenpl sinds it's the *.obj files that make the problems, OBJECTS_DIR ?

    Of course, had to make sure...
    Ok, so I added this entry to the pro file:

    OBJECTS_DIR = K:\obj
    

    And for some reason it works now, nice call!
    The generated Makefile.Release is no longer corrupted.


  • Lifetime Qt Champion

    @Bremenpl said in MSVC fatal error LNK1181: cannot open input file:

    OBJECTS_DIR = K:\obj

    Just a note: you should use / instead of \ in pro files even on Windows.



  • @jsulm It would be best for me to use something like:

    OBJECTS_DIR = config_name/obj
    

    But for over half hour I cannot figure out what is the variable name in pro file storing the current build config name...



  • @jsulm Btw, I have removed the OBJECTS_DIR entry and now the compilation is correct. All obj files are placed in the default location...


Log in to reply