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

Qt5Network.dll fatal error LNK1169: one or more multiply defined symbols found in game programming



  • build qt 5.9.4 source code on win7 VS2013 64bit and I got the error.


  • Lifetime Qt Champion

    Hi,

    You have to give more details about where it's happening.



  • The error is :
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /BASE:0x64000000 /INCREMENTAL:NO /DLL /SUBSYSTEM:WINDOWS /VERSION:5.9 /MANIFEST:embed /OUT:....\lib\Qt5Network.dll @C:\Users\LK-JL\AppData\Local\Temp\nm2858.tmp
    5>qhttp2protocolhandler.obj : error LNK2005: "private: static unsigned int const QHttp2ProtocolHandler::maxAcceptableTableSize" (?maxAcceptableTableSize@QHttp2ProtocolHandler@@0IB) 已经在 qhttpnetworkconnectionchannel.obj 中定义
    5>qhttp2protocolhandler.obj : error LNK2005: "private: static int const QHttp2ProtocolHandler::sessionMaxRecvWindowSize" (?sessionMaxRecvWindowSize@QHttp2ProtocolHandler@@0HB) 已经在 qhttpnetworkconnectionchannel.obj 中定义
    5>qhttp2protocolhandler.obj : error LNK2005: "private: static int const QHttp2ProtocolHandler::streamInitialRecvWindowSize" (?streamInitialRecvWindowSize@QHttp2ProtocolHandler@@0HB) 已经在 qhttpnetworkconnectionchannel.obj 中定义
    5> building library ....\lib\Qt5Network.lib 和对象 ....\lib\Qt5Network.exp
    5>....\lib\Qt5Network.dll : fatal error LNK1169: one or more multiply defined symbols found in programming


  • Lifetime Qt Champion

    How are you building Qt ?



  • My custom make file is :

    Download and build Qt5

    include(cmake/Externals.cmake)

    List of modules can be found in git repo here: github.com/qt/qt5

    set(MODULES_TO_EXCLUDE
    -skip qt3d
    -skip qtactiveqt
    -skip qtandroidextras
    -skip qtcanvas3d
    -skip qtcharts
    -skip qtconnectivity
    -skip qtdatavis3d
    -skip qtdeclarative
    -skip qtdoc
    -skip qtdocgallery
    -skip qtenginio
    -skip qtfeedback
    -skip qtgamepad
    -skip qtgraphicaleffects
    -skip qtimageformats
    -skip qtlocation
    -skip qtmacextras
    -skip qtnetworkauth
    -skip qtpim
    -skip qtpurchasing
    -skip qtqa
    -skip qtquick1
    -skip qtquickcontrols
    -skip qtquickcontrols2
    -skip qtremoteobjects
    -skip qtrepotools
    -skip qtscript
    -skip qtscxml
    -skip qtsensors
    -skip qtserialbus
    -skip qtserialport
    -skip qtspeech
    -skip qtsvg
    -skip qtsystems
    -skip qttools
    -skip qttranslations
    -skip qtvirtualkeyboard
    -skip qtwayland
    -skip qtwebchannel
    -skip qtwebengine
    -skip qtwebsockets
    -skip qtwebview
    -skip qtwinextras
    -skip qtx11extras
    -skip qtxmlpatterns
    )

    if(WIN32)
    #set(BUILD_COMMAND set CL=/MP; nmake)
    set(BUILD_COMMAND nmake)
    set(CONFIGURE_COMMAND ${FAST_EXTERNAL_BUILD_DIR}/qt5/src/qt5/configure.bat)
    set(URL "http://download.qt.io/archive/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.zip")
    set(URL_HASH SHA256=b6cdb6ecc70f4194cd55d6aff2d3e4c964b9abf9a204e12410dd22261ff7ff3b)
    set(OPTIONS
    -opensource;
    -confirm-license;
    -release;
    -no-compile-examples;
    -no-openssl;
    -no-libproxy;
    -no-qml-debug;
    -nomake tools;
    -nomake tests;
    -opengl desktop;
    -qt-zlib;
    -qt-libpng;
    -qt-libjpeg;
    -qt-freetype;
    ${MODULES_TO_EXCLUDE}
    )
    else()
    set(BUILD_COMMAND make -j4)
    set(CONFIGURE_COMMAND ${FAST_EXTERNAL_BUILD_DIR}/qt5/src/qt5/configure)
    set(URL "http://download.qt.io/archive/qt/5.9/5.9.4/single/qt-everywhere-opensource-src-5.9.4.tar.xz")
    set(URL_HASH SHA256=e3acd9cbeafba3aed9f14592f4d70bf0b255e0203943e8d2b4235002268274d5)
    if(APPLE)
    set(OPTIONS
    -opensource;
    -confirm-license;
    -release;
    -no-compile-examples;
    -no-openssl;
    -no-libproxy;
    -no-qml-debug;
    -nomake tools;
    -nomake tests;
    -opengl desktop;
    -qt-zlib;
    -qt-libpng;
    -qt-libjpeg;
    -no-directfb;
    -no-framework;
    ${MODULES_TO_EXCLUDE}
    )
    else()
    set(OPTIONS
    -opensource;
    -confirm-license;
    -release;
    -no-compile-examples;
    -no-openssl;
    -no-libproxy;
    -no-qml-debug;
    -nomake tools;
    -nomake tests;
    -opengl desktop;
    -qt-zlib;
    -qt-libpng;
    -qt-libjpeg;
    -system-freetype;
    -qt-xcb;
    -qt-xkbcommon;
    -no-directfb;
    -no-linuxfb;
    -fontconfig;
    ${MODULES_TO_EXCLUDE}
    )
    endif()
    endif()

    ExternalProject_Add(qt5
    PREFIX ${FAST_EXTERNAL_BUILD_DIR}/qt5
    BINARY_DIR ${FAST_EXTERNAL_BUILD_DIR}/qt5
    URL ${URL}
    URL_HASH ${URL_HASH}
    CONFIGURE_COMMAND
    ${CONFIGURE_COMMAND}
    -prefix ${FAST_EXTERNAL_INSTALL_DIR};
    ${OPTIONS}
    BUILD_COMMAND
    ${BUILD_COMMAND}
    INSTALL_COMMAND
    ${BUILD_COMMAND} install

    )
    if(WIN32)
    set(Qt5Gui_LIBRARY Qt5Gui.lib)
    set(Qt5Core_LIBRARY Qt5Core.lib)
    set(Qt5Widgets_LIBRARY Qt5Widgets.lib)
    set(Qt5OpenGL_LIBRARY Qt5OpenGL.lib)
    set(Qt5Multimedia_LIBRARY Qt5Multimedia.lib)
    set(Qt5MultimediaWidgets_LIBRARY Qt5MultimediaWidgets.lib)
    else()
    set(Qt5Gui_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Gui${CMAKE_SHARED_LIBRARY_SUFFIX})
    set(Qt5Core_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Core${CMAKE_SHARED_LIBRARY_SUFFIX})
    set(Qt5Widgets_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Widgets${CMAKE_SHARED_LIBRARY_SUFFIX})
    set(Qt5OpenGL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5OpenGL${CMAKE_SHARED_LIBRARY_SUFFIX})
    set(Qt5Multimedia_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Multimedia${CMAKE_SHARED_LIBRARY_SUFFIX})
    set(Qt5MultimediaWidgets_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5MultimediaWidgets${CMAKE_SHARED_LIBRARY_SUFFIX})
    endif()
    list(APPEND FAST_EXTERNAL_DEPENDENCIES qt5)

    CMake GUI configure and Generate with VS2013 64bit:
    0_1527469140296_73e709d9-65e1-47e7-8bf5-7adee88d0650-image.png
    CMake Deprecation Warning at CMakeLists.txt:49 (cmake_policy):
    The OLD behavior for policy CMP0043 will be removed from a future version
    of CMake.

    The cmake-policies(7) manual explains that the OLD behaviors of all
    policies are deprecated and that a policy should be set to OLD only under
    specific short-term circumstances. Projects should be ported to the NEW
    behavior and not rely on setting a policy to OLD.

    Found OpenMP_C: -openmp (found version "2.0")
    Found OpenMP_CXX: -openmp (found version "2.0")
    Found OpenMP: TRUE (found version "2.0")
    -- OpenMP was detected. Using OpenMP to speed up some calculations.
    Looking for CL_VERSION_2_0
    Looking for CL_VERSION_2_0 - not found
    Looking for CL_VERSION_1_2
    Looking for CL_VERSION_1_2 - found
    Found OpenCL: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/OpenCL.lib (found version "1.2")
    -- OpenCL library: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/OpenCL.lib
    Found OpenGL: opengl32
    Performing Test COMPILER_HAS_DEPRECATED_ATTR
    Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
    Performing Test COMPILER_HAS_DEPRECATED
    Performing Test COMPILER_HAS_DEPRECATED - Success
    -- LIBS: Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;Qt5OpenGL.lib;Qt5Multimedia.lib;Qt5MultimediaWidgets.lib;debug;zlibd.lib;optimized;zlib.lib;ofstd.lib;oflog.lib;dcmdata.lib;dcmimgle.lib;OpenIGTLink.lib C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/OpenCL.lib;opengl32;glu32
    -- Python module not enabled in CMake, Python bindings will NOT be created.
    Configuring done
    Generating done


  • Lifetime Qt Champion

    Just to be sure: you are building a custom Qt as part of your project build process ?



  • Move the static vars to qhttp2protocolhandler.cpp, it will work. Remove the assignment in qhttp2protocolhandler_p.h。
    //const qint32 QHttp2ProtocolHandler::sessionMaxRecvWindowSize;
    //const qint32 QHttp2ProtocolHandler::streamInitialRecvWindowSize;
    //const quint32 QHttp2ProtocolHandler::maxAcceptableTableSize;
    const quint32 QHttp2ProtocolHandler::maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize;
    const qint32 QHttp2ProtocolHandler::sessionMaxRecvWindowSize = Http2::defaultSessionWindowSize * 10;
    const qint32 QHttp2ProtocolHandler::streamInitialRecvWindowSize = Http2::defaultSessionWindowSize;



  • @SGaist Yes.


  • Lifetime Qt Champion

    Isn't that a bit overkill ?




  • Lifetime Qt Champion

    It's pretty unusual to have the building of a framework as big as Qt as part of the build process of an application,


Log in to reply