PDA

View Full Version : Qt compilation error



anh5kor
18th December 2015, 05:29
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::operator=(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.e xe : 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

d_stranz
18th December 2015, 17:10
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 (http://stackoverflow.com/questions/5727815/how-to-set-iterator-debug-level-in-vs2010) to set the value to compile your example code (of course, change "0" to "2").

anh5kor
21st December 2015, 10:51
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

d_stranz
21st December 2015, 16:59
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"?

anh5kor
22nd December 2015, 12:01
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

bdv1983
14th December 2017, 09:25
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.

d_stranz
14th December 2017, 14:37
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.