Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Build static linked app with Qt5 on Windows
QtWS25 Last Chance

Build static linked app with Qt5 on Windows

Scheduled Pinned Locked Moved Solved General and Desktop
c++ windowsnmakestatic linking
5 Posts 2 Posters 6.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Redleouf
    wrote on 4 Aug 2016, 05:01 last edited by
    #1

    I am new to developing on Windows and Qt and I am trying to build my app with static linking to avoid errors such as "missing msvcp140.dll" on systems who lack Visual C++ Redistibutable. I know there is other solutions for that problem but I still want to build my app with static linking to only have one executable people can launch.

    I am on Windows 7 x64 and use the latest Qt5 version I built from source with static linking using thoses commands : perl init-repository && configure -developer-build -opensource -confirm-license -nomake examples -nomake tests -static && SET CL=/MP && configure -developer-build -opensource -confirm-license -nomake examples -nomake tests -static -opengl desktop && nmake

    I then use nmake from Visual Studio 2015 to compile.

    Here is my .pro file from my project :

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = LauncherCPC
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    RESOURCES = resources.qrc
    
    RC_FILE = LauncherCPC.rc
    
    CONFIG += static
    #CONFIG += staticlib
    CONFIG += debug_and_release
    
    DEFINES += QT_NODLL
    DEFINES += QT_STATIC_BUILD
    
    QMAKE_CFLAGS_RELEASE += /MT
    QMAKE_CXXFLAGS_RELEASE += /MT
    QMAKE_CFLAGS_RELEASE -= -MD
    QMAKE_CXXFLAGS_RELEASE -= -MD
    

    And here are the errors I get when launching nmake (I removed some of the errors in the log because it was all the same and too many of them) :

    	"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe" -f Makefile.Release
    	call D:\Divers\Programmation\QT\LauncherCPC\uic_wrapper.bat mainwindow.ui -o ui_mainwindow.h
    	D:\ProgramData\qt5\qtbase\bin\rcc.exe -name resources resources.qrc -o release\qrc_resources.cpp
    	D:\ProgramData\qt5\qtbase\bin\moc.exe -DUNICODE -DWIN32 -DWIN64 -DQT_NODLL -DQT_STATIC_BUILD -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -D_MSC_VER=1900 -D_WIN32 -D_WIN64 -ID:/ProgramData/qt5/qtbase/mkspecs/win32-msvc2015 -ID:/Divers/Programmation/QT/LauncherCPC -ID:/ProgramData/qt5/qtbase/include -ID:/ProgramData/qt5/qtbase/include/QtWidgets -ID:/ProgramData/qt5/qtbase/include/QtGui -ID:/ProgramData/qt5/qtbase/include/QtCore mainwindow.h -o release\moc_mainwindow.cpp
    	rc -DUNICODE -DWIN32 -DWIN64 -DQT_NODLL -DQT_STATIC_BUILD -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -fo release\LauncherCPC.res LauncherCPC.rc
    Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
    
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    	cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -O2 /MT -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -EHsc -DUNICODE -DWIN32 -DWIN64 -DQT_NODLL -DQT_STATIC_BUILD -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I. -I..\..\..\..\ProgramData\qt5\qtbase\include -I..\..\..\..\ProgramData\qt5\qtbase\include\QtWidgets -I..\..\..\..\ProgramData\qt5\qtbase\include\QtGui -I..\..\..\..\ProgramData\qt5\qtbase\include\QtCore -Irelease -I. -I..\..\..\..\ProgramData\qt5\qtbase\mkspecs\win32-msvc2015 -Forelease\ @C:\Users\Redleouf\AppData\Local\Temp\nmD195.tmp
    main.cpp
    mainwindow.cpp
    launchercpc_plugin_import.cpp
    Generating Code...
    	cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -O2 /MT -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -EHsc -DUNICODE -DWIN32 -DWIN64 -DQT_NODLL -DQT_STATIC_BUILD -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I. -I..\..\..\..\ProgramData\qt5\qtbase\include -I..\..\..\..\ProgramData\qt5\qtbase\include\QtWidgets -I..\..\..\..\ProgramData\qt5\qtbase\include\QtGui -I..\..\..\..\ProgramData\qt5\qtbase\include\QtCore -Irelease -I. -I..\..\..\..\ProgramData\qt5\qtbase\mkspecs\win32-msvc2015 -Forelease\ @C:\Users\Redleouf\AppData\Local\Temp\nmDB56.tmp
    qrc_resources.cpp
    moc_mainwindow.cpp
    Generating Code...
    	link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:release\LauncherCPC.exe @C:\Users\Redleouf\AppData\Local\Temp\nmECF4.tmp
    Qt5Widgets.lib(qwidget.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj
    ...
    Qt5Core.lib(cached-powers.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj
    msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) already defined in libcpmt.lib(xthrow.obj)
    msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPEBD@Z) already defined in libcpmt.lib(xthrow.obj)
    qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj
    LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    qtpcre.lib(pcre16_jit_compile.obj) : warning LNK4049: locally defined symbol memmove imported
    Qt5Core.lib(fast-dtoa.obj) : warning LNK4049: locally defined symbol memmove imported
    ...
    Qt5Core.lib(qdatetimeparser.obj) : warning LNK4217: locally defined symbol memmove imported in function "public: bool __cdecl QDateTimeParser::parseFormat(class QString const &)" (?parseFormat@QDateTimeParser@@QEAA_NAEBVQString@@@Z)
    ...
    Qt5Core.lib(qdir.obj) : warning LNK4217: locally defined symbol memmove imported in function __catch$??$_Construct@PEAVQPointF@@@?$vector@VQPointF@@V?$allocator@VQPointF@@@std@@@std@@QEAAXPEAVQPointF@@0Uforward_iterator_tag@1@@Z$0
    ...
    Qt5Core.lib(qdatetime.obj) : warning LNK4217: locally defined symbol memmove imported in function __catch$?detach_helper_grow@?$QList@VQPointF@@@@AEAAPEAUNode@1@HH@Z$2
    ...
    Qt5Core.lib(qabstractitemmodel.obj) : warning LNK4217: locally defined symbol memmove imported in function "protected: void __cdecl QAbstractItemModel::endMoveRows(void)" (?endMoveRows@QAbstractItemModel@@IEAAXXZ)
    ...
    Qt5Gui.lib(qtexthtmlparser.obj) : warning LNK4217: locally defined symbol memmove imported in function "public: void __cdecl QTextHtmlParserNode::applyCssDeclarations(class QVector<struct QCss::Declaration> const &,class QTextDocument const *)" (?applyCssDeclarations@QTextHtmlParserNode@@QEAAXAEBV?$QVector@UDeclaration@QCss@@@@PEBVQTextDocument@@@Z)
    ...
    Qt5Widgets.lib(qgraphicsitem.obj) : warning LNK4217: locally defined symbol memmove imported in function "public: struct QGraphicsItemPrivate::ExtraStruct * __cdecl QVector<struct QGraphicsItemPrivate::ExtraStruct>::erase(struct QGraphicsItemPrivate::ExtraStruct *,struct QGraphicsItemPrivate::ExtraStruct *)" (?erase@?$QVector@UExtraStruct@QGraphicsItemPrivate@@@@QEAAPEAUExtraStruct@QGraphicsItemPrivate@@PEAU23@0@Z)
    ...
    Qt5Core.lib(qbytearray.obj) : warning LNK4217: locally defined symbol free imported in function "public: class QByteArray & __cdecl QByteArray::prepend(class QByteArray const &)" (?prepend@QByteArray@@QEAAAEAV1@AEBV1@@Z)
    ...
    qtharfbuzzng.lib(hb-ot-shape-complex-arabic.obj) : warning LNK4217: locally defined symbol free imported in function "public: bool __cdecl OT::SubstLookup::serialize_ligature(struct OT::hb_serialize_context_t *,unsigned int,struct OT::Supplier<struct OT::GlyphID> &,struct OT::Supplier<unsigned int> &,unsigned int,struct OT::Supplier<struct OT::GlyphID> &,struct OT::Supplier<unsigned int> &,struct OT::Supplier<struct OT::GlyphID> &)" (?serialize_ligature@SubstLookup@OT@@QEAA_NPEAUhb_serialize_context_t@2@IAEAU?$Supplier@UGlyphID@OT@@@2@AEAU?$Supplier@I@2@I121@Z)
    ...
    Qt5Gui.lib(qtexttable.obj) : warning LNK4217: locally defined symbol free imported in function "public: void __cdecl QTextTable::mergeCells(int,int,int,int)" (?mergeCells@QTextTable@@QEAAXHHHH@Z)
    ...
    Qt5Widgets.lib(qsplitter.obj) : warning LNK4217: locally defined symbol free imported in function "public: void * __cdecl QtSharedPointer::ExternalRefCountData::`scalar deleting destructor'(unsigned int)" (??_GExternalRefCountData@QtSharedPointer@@QEAAPEAXI@Z)
    Qt5Widgets.lib(qwidgetbackingstore.obj) : warning LNK4217: locally defined symbol free imported in function "public: __cdecl QVarLengthArray<class QWidget *,16>::~QVarLengthArray<class QWidget *,16>(void)" (??1?$QVarLengthArray@PEAVQWidget@@$0BA@@@QEAA@XZ)
    Qt5Widgets.lib(qmainwindowlayout.obj) : warning LNK4049: locally defined symbol free imported
    Qt5Widgets.lib(qgridlayout.obj) : warning LNK4049: locally defined symbol free imported
    Qt5Widgets.lib(qlayoutengine.obj) : warning LNK4049: locally defined symbol free imported
    qtpcre.lib(pcre16_globals.obj) : warning LNK4049: locally defined symbol malloc imported
    Qt5Core.lib(qmutexpool.obj) : warning LNK4049: locally defined symbol malloc imported
    ...
    Qt5Gui.lib(qtexttable.obj) : warning LNK4217: locally defined symbol malloc imported in function "public: void __cdecl QTextTable::removeColumns(int,int)" (?removeColumns@QTextTable@@QEAAXHH@Z)
    ...
    Qt5Widgets.lib(qwidgetbackingstore.obj) : warning LNK4217: locally defined symbol malloc imported in function "public: __cdecl QVarLengthArray<class QWidget *,16>::QVarLengthArray<class QWidget *,16>(int)" (??0?$QVarLengthArray@PEAVQWidget@@$0BA@@@QEAA@H@Z)
    ...
    Qt5Widgets.lib(qmessagebox.obj) : warning LNK4217: locally defined symbol strchr imported in function "public: void __cdecl QMessageBox::open(class QObject *,char const *)" (?open@QMessageBox@@QEAAXPEAVQObject@@PEBD@Z)
    qtharfbuzzng.lib(hb-ot-tag.obj) : warning LNK4049: locally defined symbol strchr imported
    qtharfbuzzng.lib(hb-shaper.obj) : warning LNK4049: locally defined symbol strchr imported
    Qt5Core.lib(qobject.obj) : warning LNK4049: locally defined symbol strchr imported
    Qt5Core.lib(qmimemagicrule.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Core.lib(moc_qfilesystemwatcher_polling_p.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Core.lib(qfsfileengine_iterator.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    ...
    Qt5Gui.lib(qcssparser.obj) : warning LNK4217: locally defined symbol _invalid_parameter_noinfo_noreturn imported in function "public: enum QCss::PositionMode __cdecl QCss::Declaration::positionValue(void)const " (?positionValue@Declaration@QCss@@QEBA?AW4PositionMode@2@XZ)
    ...
    qwindows.lib(qwindowsglcontext.obj) : warning LNK4217: locally defined symbol _invalid_parameter_noinfo_noreturn imported in function "private: __cdecl QOpenGLStaticContext::QOpenGLStaticContext(void)" (??0QOpenGLStaticContext@@AEAA@XZ)
    qwindows.lib(iaccessible2.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Gui.lib(qbrush.obj) : warning LNK4217: locally defined symbol _invalid_parameter_noinfo_noreturn imported in function "class QNullBrushData * __cdecl `anonymous namespace'::Q_QGS_nullBrushInstance_holder::innerFunction(void)" (?innerFunction@Q_QGS_nullBrushInstance_holder@?A0x7e294c07@@YAPEAVQNullBrushData@@XZ)
    Qt5Gui.lib(qkeysequence.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qlineedit_p.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qcalendarwidget.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qdirmodel.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qfileinfogatherer.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qaction.obj) : warning LNK4217: locally defined symbol _invalid_parameter_noinfo_noreturn imported in function "class stdext::checked_array_iterator<class QKeySequence const *> __cdecl stdext::make_checked_array_iterator<class QKeySequence const *>(class QKeySequence const *,unsigned __int64,unsigned __int64)" (??$make_checked_array_iterator@PEBVQKeySequence@@@stdext@@YA?AV?$checked_array_iterator@PEBVQKeySequence@@@0@PEBVQKeySequence@@_K1@Z)
    Qt5Widgets.lib(qlineedit.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qerrormessage.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Widgets.lib(qwidgetlinecontrol.obj) : warning LNK4049: locally defined symbol _invalid_parameter_noinfo_noreturn imported
    Qt5Core.lib(bignum.obj) : warning LNK4217: locally defined symbol exit imported in function "public: void __cdecl double_conversion::Bignum::AddUInt64(unsigned __int64)" (?AddUInt64@Bignum@double_conversion@@QEAAX_K@Z)
    Qt5Core.lib(double-conversion.obj) : warning LNK4049: locally defined symbol exit imported
    Qt5Core.lib(bignum-dtoa.obj) : warning LNK4049: locally defined symbol exit imported
    Qt5Core.lib(fast-dtoa.obj) : warning LNK4049: locally defined symbol exit imported
    Qt5Core.lib(strtod.obj) : warning LNK4049: locally defined symbol exit imported
    Qt5Widgets.lib(qerrormessage.obj) : warning LNK4217: locally defined symbol exit imported in function "protected: virtual void __cdecl QErrorMessage::done(int)" (?done@QErrorMessage@@MEAAXH@Z)
    Qt5Gui.lib(qwindow.obj) : warning LNK4049: locally defined symbol exit imported
    Qt5Gui.lib(jerror.obj) : warning LNK4049: locally defined symbol exit imported
    Qt5Core.lib(qlogging.obj) : warning LNK4049: locally defined symbol exit imported
    ...
    qtiff.lib(tif_predict.obj) : warning LNK4217: locally defined symbol __stdio_common_vfprintf imported in function PredictorSetupDecode
    Qt5Gui.lib(qguiapplication.obj) : warning LNK4217: locally defined symbol isdigit imported in function "public: static struct QWindowGeometrySpecification __cdecl QWindowGeometrySpecification::fromArgument(class QByteArray const &)" (?fromArgument@QWindowGeometrySpecification@@SA?AU1@AEBVQByteArray@@@Z)
    Qt5Gui.lib(qppmhandler.obj) : warning LNK4049: locally defined symbol isdigit imported
    Qt5Gui.lib(qxbmhandler.obj) : warning LNK4049: locally defined symbol isdigit imported
    qtpcre.lib(pcre16_compile.obj) : warning LNK4049: locally defined symbol isdigit imported
    Qt5Gui.lib(qppmhandler.obj) : warning LNK4217: locally defined symbol isspace imported in function "bool __cdecl read_pbm_header(class QIODevice *,char &,int &,int &,int &)" (?read_pbm_header@@YA_NPEAVQIODevice@@AEADAEAH22@Z)
    Qt5Gui.lib(qxbmhandler.obj) : warning LNK4217: locally defined symbol strcpy_s imported in function "bool __cdecl write_xbm_image(class QImage const &,class QIODevice *,class QString const &)" (?write_xbm_image@@YA_NAEBVQImage@@PEAVQIODevice@@AEBVQString@@@Z)
    ...
    Qt5Core.lib(qfilesystemengine_win.obj) : warning LNK4049: locally defined symbol _errno imported
    qtpng.lib(pngread.obj) : warning LNK4217: locally defined symbol _errno imported in function png_image_begin_read_from_file
    qtpng.lib(pngwrite.obj) : warning LNK4049: locally defined symbol _errno imported
    qtharfbuzzng.lib(hb-shape.obj) : warning LNK4217: locally defined symbol _errno imported in function "bool __cdecl parse_bool(char const * *,char const *,unsigned int *)" (?parse_bool@@YA_NPEAPEBDPEBDPEAI@Z)
    qtharfbuzzng.lib(hb-font.obj) : warning LNK4049: locally defined symbol _errno imported
    qtpng.lib(pngerror.obj) : warning LNK4217: locally defined symbol abort imported in function png_safe_error
    qtharfbuzzng.lib(hb-shape.obj) : warning LNK4217: locally defined symbol strtol imported in function "bool __cdecl parse_uint(char const * *,char const *,unsigned int *)" (?parse_uint@@YA_NPEAPEBDPEBDPEAI@Z)
    qtharfbuzzng.lib(hb-font.obj) : warning LNK4217: locally defined symbol strtoul imported in function "int __cdecl hb_codepoint_parse(char const *,unsigned int,int,unsigned int *)" (?hb_codepoint_parse@@YAHPEBDIHPEAI@Z)
    Qt5Core.lib(qbytearray.obj) : warning LNK4217: locally defined symbol strncpy_s imported in function "char * __cdecl qstrncpy(char *,char const *,unsigned int)" (?qstrncpy@@YAPEADPEADPEBDI@Z)
    Qt5Core.lib(qcoreapplication.obj) : warning LNK4217: locally defined symbol __p___argc imported in function "bool __cdecl isArgvModified(int,char * *)" (?isArgvModified@@YA_NHPEAPEAD@Z)
    ...
    Qt5Core.lib(qfsfileengine.obj) : warning LNK4217: locally defined symbol _write imported in function "public: __int64 __cdecl QFSFileEnginePrivate::writeFdFh(char const *,__int64)" (?writeFdFh@QFSFileEnginePrivate@@QEAA_JPEBD_J@Z)
    Qt5Core.lib(qfsfileengine_win.obj) : warning LNK4217: locally defined symbol _fileno imported in function "public: bool __cdecl QFSFileEnginePrivate::doStat(class QFlags<enum QFileSystemMetaData::MetaDataFlag>)const " (?doStat@QFSFileEnginePrivate@@QEBA_NV?$QFlags@W4MetaDataFlag@QFileSystemMetaData@@@@@Z)
    Qt5Core.lib(qfsfileengine_win.obj) : warning LNK4217: locally defined symbol _open_osfhandle imported in function "public: int __cdecl QFSFileEnginePrivate::nativeHandle(void)const " (?nativeHandle@QFSFileEnginePrivate@@QEBAHXZ)
    ...
    Qt5Widgets.lib(qwindowsxpstyle.obj) : error LNK2019: unresolved external symbol __imp_wcsrchr referenced in function "public: virtual void __cdecl QWindowsXPStyle::drawPrimitive(enum QStyle::PrimitiveElement,class QStyleOption const *,class QPainter *,class QWidget const *)const " (?drawPrimitive@QWindowsXPStyle@@UEBAXW4PrimitiveElement@QStyle@@PEBVQStyleOption@@PEAVQPainter@@PEBVQWidget@@@Z)
    ...
    Qt5Gui.lib(qstroker.obj) : error LNK2001: unresolved external symbol __imp__dtest
    Qt5Core.lib(qnumeric.obj) : error LNK2001: unresolved external symbol __imp__dtest
    Qt5Core.lib(qline.obj) : error LNK2001: unresolved external symbol __imp__dtest
    Qt5Gui.lib(qxpmhandler.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function _vsscanf_s_l
    Qt5Gui.lib(jmemmgr.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
    Qt5Gui.lib(jmemmgr.obj) : error LNK2019: unresolved external symbol __imp_getenv referenced in function jinit_memory_mgr
    qtharfbuzzng.lib(hb-common.obj) : error LNK2001: unresolved external symbol __imp_getenv
    qtharfbuzzng.lib(hb-shaper.obj) : error LNK2001: unresolved external symbol __imp_getenv
    qtpng.lib(pngread.obj) : error LNK2019: unresolved external symbol __imp_strerror referenced in function png_image_begin_read_from_file
    qtpng.lib(pngwrite.obj) : error LNK2001: unresolved external symbol __imp_strerror
    Qt5Core.lib(qsystemerror.obj) : error LNK2001: unresolved external symbol __imp_strerror
    qtpng.lib(png.obj) : error LNK2019: unresolved external symbol __imp_frexp referenced in function png_ascii_from_fp
    qtpng.lib(png.obj) : error LNK2019: unresolved external symbol __imp_modf referenced in function png_ascii_from_fp
    qtpng.lib(pngget.obj) : error LNK2019: unresolved external symbol __imp_atof referenced in function png_get_sCAL
    qtpng.lib(pngwrite.obj) : error LNK2019: unresolved external symbol __imp_ferror referenced in function png_image_write_to_file
    qtpng.lib(pngwrite.obj) : error LNK2019: unresolved external symbol __imp_remove referenced in function png_image_write_to_file
    qtpng.lib(pngwrite.obj) : error LNK2019: unresolved external symbol __imp__gmtime64 referenced in function gmtime
    qtpng.lib(pngwio.obj) : error LNK2019: unresolved external symbol __imp_fwrite referenced in function png_default_write_data
    Qt5Core.lib(qfsfileengine.obj) : error LNK2001: unresolved external symbol __imp_fwrite
    qtharfbuzzng.lib(hb-common.obj) : error LNK2019: unresolved external symbol __imp_strdup referenced in function "public: struct hb_language_item_t & __cdecl hb_language_item_t::operator=(char const *)" (??4hb_language_item_t@@QEAAAEAU0@PEBD@Z)
    OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp_strdup
    qtharfbuzzng.lib(hb-common.obj) : error LNK2019: unresolved external symbol __imp_setlocale referenced in function hb_language_get_default
    Qt5Core.lib(qglobal.obj) : error LNK2019: unresolved external symbol __imp_srand referenced in function "void __cdecl qsrand(unsigned int)" (?qsrand@@YAXI@Z)
    Qt5Core.lib(qglobal.obj) : error LNK2019: unresolved external symbol __imp_getenv_s referenced in function "int __cdecl qEnvironmentVariableIntValue(char const *,bool *)" (?qEnvironmentVariableIntValue@@YAHPEBDPEA_N@Z)
    Qt5Core.lib(qglobal.obj) : error LNK2019: unresolved external symbol __imp__putenv_s referenced in function "bool __cdecl qputenv(char const *,class QByteArray const &)" (?qputenv@@YA_NPEBDAEBVQByteArray@@@Z)
    Qt5Core.lib(qnumeric.obj) : error LNK2019: unresolved external symbol __imp__fdtest referenced in function "bool __cdecl isfinite<float>(float)" (??$isfinite@M@@YA_NM@Z)
    Qt5Core.lib(qdatetime.obj) : error LNK2019: unresolved external symbol __imp__get_timezone referenced in function "bool __cdecl epochMSecsToLocalTime(__int64,class QDate *,class QTime *,enum QDateTimePrivate::DaylightStatus *)" (?epochMSecsToLocalTime@@YA_N_JPEAVQDate@@PEAVQTime@@PEAW4DaylightStatus@QDateTimePrivate@@@Z)
    Qt5Core.lib(qdatetime.obj) : error LNK2019: unresolved external symbol __imp__get_tzname referenced in function "class QString __cdecl qt_tzname(enum QDateTimePrivate::DaylightStatus)" (?qt_tzname@@YA?AVQString@@W4DaylightStatus@QDateTimePrivate@@@Z)
    Qt5Core.lib(qdatetime.obj) : error LNK2019: unresolved external symbol __imp__localtime64_s referenced in function "bool __cdecl qt_localtime(__int64,class QDate *,class QTime *,enum QDateTimePrivate::DaylightStatus *)" (?qt_localtime@@YA_N_JPEAVQDate@@PEAVQTime@@PEAW4DaylightStatus@QDateTimePrivate@@@Z)
    Qt5Core.lib(qdatetime.obj) : error LNK2019: unresolved external symbol __imp__mktime64 referenced in function "__int64 __cdecl qt_mktime(class QDate *,class QTime *,enum QDateTimePrivate::DaylightStatus *,class QString *,bool *)" (?qt_mktime@@YA_JPEAVQDate@@PEAVQTime@@PEAW4DaylightStatus@QDateTimePrivate@@PEAVQString@@PEA_N@Z)
    Qt5Core.lib(qdatetime.obj) : error LNK2019: unresolved external symbol __imp__tzset referenced in function "bool __cdecl epochMSecsToLocalTime(__int64,class QDate *,class QTime *,enum QDateTimePrivate::DaylightStatus *)" (?epochMSecsToLocalTime@@YA_N_JPEAVQDate@@PEAVQTime@@PEAW4DaylightStatus@QDateTimePrivate@@@Z)
    Qt5Core.lib(qfile.obj) : error LNK2019: unresolved external symbol __imp__ftelli64 referenced in function "public: bool __cdecl QFile::open(struct _iobuf *,class QFlags<enum QIODevice::OpenModeFlag>,class QFlags<enum QFileDevice::FileHandleFlag>)" (?open@QFile@@QEAA_NPEAU_iobuf@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@V?$QFlags@W4FileHandleFlag@QFileDevice@@@@@Z)
    Qt5Core.lib(qfsfileengine.obj) : error LNK2001: unresolved external symbol __imp__ftelli64
    Qt5Core.lib(qthread_win.obj) : error LNK2019: unresolved external symbol __imp__beginthreadex referenced in function "public: void __cdecl QThread::start(enum QThread::Priority)" (?start@QThread@@QEAAXW4Priority@1@@Z)
    Qt5Core.lib(qthread_win.obj) : error LNK2019: unresolved external symbol __imp__endthreadex referenced in function "protected: static void __cdecl QThread::setTerminationEnabled(bool)" (?setTerminationEnabled@QThread@@KAX_N@Z)
    Qt5Core.lib(qsimd.obj) : error LNK2019: unresolved external symbol __imp_puts referenced in function "void __cdecl qDumpCPUFeatures(void)" (?qDumpCPUFeatures@@YAXXZ)
    Qt5Core.lib(qcoreapplication_win.obj) : error LNK2019: unresolved external symbol __imp__strdup referenced in function "void __cdecl qWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int,int &,class QVector<char *> &)" (?qWinMain@@YAXPEAUHINSTANCE__@@0PEADHAEAHAEAV?$QVector@PEAD@@@Z)
    OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp__strdup
    Qt5Core.lib(qfilesystemengine_win.obj) : error LNK2019: unresolved external symbol __imp__waccess referenced in function "public: static bool __cdecl QFileSystemEngine::fillPermissions(class QFileSystemEntry const &,class QFileSystemMetaData &,class QFlags<enum QFileSystemMetaData::MetaDataFlag>)" (?fillPermissions@QFileSystemEngine@@SA_NAEBVQFileSystemEntry@@AEAVQFileSystemMetaData@@V?$QFlags@W4MetaDataFlag@QFileSystemMetaData@@@@@Z)
    Qt5Core.lib(qfilesystemengine_win.obj) : error LNK2019: unresolved external symbol __imp__wchmod referenced in function "public: static bool __cdecl QFileSystemEngine::setPermissions(class QFileSystemEntry const &,class QFlags<enum QFileDevice::Permission>,class QSystemError &,class QFileSystemMetaData *)" (?setPermissions@QFileSystemEngine@@SA_NAEBVQFileSystemEntry@@V?$QFlags@W4Permission@QFileDevice@@@@AEAVQSystemError@@PEAVQFileSystemMetaData@@@Z)
    Qt5Core.lib(qfsfileengine.obj) : error LNK2019: unresolved external symbol __imp_feof referenced in function "public: virtual bool __cdecl QFSFileEngine::extension(enum QAbstractFileEngine::Extension,class QAbstractFileEngine::ExtensionOption const *,class QAbstractFileEngine::ExtensionReturn *)" (?extension@QFSFileEngine@@UEAA_NW4Extension@QAbstractFileEngine@@PEBVExtensionOption@3@PEAVExtensionReturn@3@@Z)
    Qt5Core.lib(qfsfileengine_win.obj) : error LNK2001: unresolved external symbol __imp_feof
    Qt5Core.lib(qfsfileengine.obj) : error LNK2019: unresolved external symbol __imp_fgets referenced in function "public: __int64 __cdecl QFSFileEnginePrivate::readLineFdFh(char *,__int64)" (?readLineFdFh@QFSFileEnginePrivate@@QEAA_JPEAD_J@Z)
    Qt5Core.lib(qfsfileengine.obj) : error LNK2019: unresolved external symbol __imp__fseeki64 referenced in function "public: bool __cdecl QFSFileEnginePrivate::openFh(class QFlags<enum QIODevice::OpenModeFlag>,struct _iobuf *)" (?openFh@QFSFileEnginePrivate@@QEAA_NV?$QFlags@W4OpenModeFlag@QIODevice@@@@PEAU_iobuf@@@Z)
    Qt5Core.lib(qfsfileengine.obj) : error LNK2019: unresolved external symbol __imp__read referenced in function "public: __int64 __cdecl QFSFileEnginePrivate::readFdFh(char *,__int64)" (?readFdFh@QFSFileEnginePrivate@@QEAA_JPEAD_J@Z)
    Qt5Core.lib(qfsfileengine_win.obj) : error LNK2019: unresolved external symbol __imp__wgetdcwd referenced in function "public: static class QString __cdecl QFSFileEngine::currentPath(class QString const &)" (?currentPath@QFSFileEngine@@SA?AVQString@@AEBV2@@Z)
    Qt5Core.lib(qfsfileengine_win.obj) : error LNK2019: unresolved external symbol __imp__getdrive referenced in function "public: static class QString __cdecl QFSFileEngine::currentPath(class QString const &)" (?currentPath@QFSFileEngine@@SA?AVQString@@AEBV2@@Z)
    release\LauncherCPC.exe : fatal error LNK1120: 48 unresolved externals
    

    Why is this happening? How can I build my app with static linking properly? I tried with Visual Studio 2015 and the Qt5 Add-On but it does the same (I changed the compilation from MD to MT in the settings).

    I have read a lot of questions and answers on internet about all of that, but none of the solutions seems to work. I feel like my Qt5 build is not so static, but it should be.

    Note that I also have a file in my project folder that is not present in the .pro file : ui_mainwindow.h. It seemed to have been generated by Qt, I don't know if I should add it to my .pro file.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Aug 2016, 08:56 last edited by
      #2

      Hi and welcome to devnet,

      The default Qt build even if static uses the dynamic runtime. You are trying to build your application against the static runtime so it won't work.

      You also have to modify the mkspec to link to the static runtime before building Qt.

      Important note: don't forget the licensing implication when doing a static build.

      Also, drop the the -developer-build option since you're not hacking on Qt.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Redleouf
        wrote on 4 Aug 2016, 15:04 last edited by
        #3

        Thank you for your answer. So I need to rebuild my whole Qt with the -static-runtimeoption passed to configure for it to work right?

        Is that what you mean by modify the mkspec?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Aug 2016, 15:53 last edited by SGaist 8 Apr 2016, 15:54
          #4

          No but it's even better. I've missed that new option of configure. Before it, you had to modify Qt's msvc-XXX mkspec to change the runtime option passed to the compiler/linker.

          So yes, you have to rebuild Qt with it and it should be enough.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • R Offline
            R Offline
            Redleouf
            wrote on 4 Aug 2016, 18:41 last edited by
            #5

            Indeed it did the work, it is working fine now, thank you :)

            1 Reply Last reply
            0

            2/5

            4 Aug 2016, 08:56

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved