Results 1 to 7 of 7

Thread: Qt compilation error

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Question Qt compilation error

    I have downloaded a project which read/write the excel file in c++. The project is working fine in Visual studio 2010,I have to create a GUI for the same project.
    So I tried creating a new QT project in Visual Studio2010(Visual studio is already have Qt add-in).
    I added the .cpp and .hpp file of my downloaded project and tried calling the functionality from my main class.
    But when I build my project in debug mode I got the below error.
    1>moc_qt_excel.obj : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in BasicExcel.obj
    1>qrc_qt_excel.obj : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in BasicExcel.obj
    1>qt_excel.obj : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in BasicExcel.obj
    1>qtmaind.lib(qtmain_win.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in BasicExcel.obj
    1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
    1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info:perator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
    1>LIBCMTD.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
    1>D:\Others\Project\qt_excel\Win32\Debug\\qt_excel .exe : fatal error LNK1169: one or more multiply defined symbols found
    I searched in net about the error I got some solution about changing the project property->C/C++ ->code Generation->Runtime Library->Multi-threaded DLL(/MD) from Multi-threaded Dubug(/MTd) then I got the below error
    qtmaind.lib(qtmain_win.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in BasicExcel.obj
    Same project when I compiled in Release mode its compiled Properly.
    Please let me know the problem I want the project to run under debug mode also

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt compilation error

    Your Qt library was compiled with the internal macro "_ITERATOR_DEBUG_LEVEL" set to 2. Your BasicExcel.cpp file was compiled with the same macro set to 0. You cannot link two pieces of code where this macro is defined differently. Since I assume you do not want to rebuild Qt, you should follow these instructions to set the value to compile your example code (of course, change "0" to "2").

  3. The following user says thank you to d_stranz for this useful post:

    anh5kor (21st December 2015)

  4. #3
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt compilation error

    I checked the above link and added
    Project Pages / Configuration Properties / C,C++ / Preprocessor / Preprocessor Definitions.

    Add "_ITERATOR_DEBUG_LEVEL=0" to my project Property, still i got the same error.
    But my problem got solved when I kept "_ITERATOR_DEBUG_LEVEL!=0" to my project Property

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt compilation error

    But my problem got solved when I kept "_ITERATOR_DEBUG_LEVEL!=0" to my project Property
    Wrong. Did you not read the last line where I say "change "0" to "2"?

    Your preprocessor definition should read "_ITERATOR_DEBUG_LEVEL=2"

    I am surprised that your code even compiled with the != nonsense. A preprocessor definition says to the compiler, "Replace the macro '_ITERATOR_DEBUG_LEVEL' with the value '0'". How is the compiler supposed to interpret "_ITERATOR_DEBUG_LEVEL!=0"? "Don't replace '_ITERATOR_DEBUG_LEVEL' with '0', set it to anything else you want"?

  6. #5
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt compilation error

    I think you are correct..
    Strange behaviour
    When I kept "_ITERATOR_DEBUG_LEVEL!=0" my compiler was not supporting the intellisense
    But When I kept " "_ITERATOR_DEBUG_LEVEL=2" my compiler started supporting the intellisense
    But in both the case there was no error in compilation

  7. #6
    Join Date
    Dec 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt compilation error

    For the decision it is necessary to replace in project properties debug versions of libraries with release. i.e. in Property Pages->Configuration Properties->Linker->Input to replace qtmaind.lib with qtmain.lib, Qt5Cored.lib on Qt5Core.lib, etc.

  8. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt compilation error

    Totally, completely wrong. If you are compiling a release mode binary, then you must link to release mode Qt libraries. The OP was compiling a debug mode binary, in which case he should link to debug mode Qt libraries.

    The error he experienced has nothing to do with release vs. debug mode. My original answer addresses the problem he had: trying to link a debug mode binary to a debug mode library which had been built using different compiler settings.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Qt compilation error
    By saul.andrade in forum Newbie
    Replies: 1
    Last Post: 17th March 2011, 10:51
  2. Compilation Error
    By ^NyAw^ in forum General Programming
    Replies: 2
    Last Post: 30th September 2008, 18:37
  3. QT 4. Compilation error
    By mansoorulhaq in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2007, 10:32
  4. Qt 4 compilation error
    By mansoorulhaq in forum Installation and Deployment
    Replies: 1
    Last Post: 8th October 2007, 08:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.