June 4, 2012

bmedina bmedina
Lab Rat
2 posts

Building Qt 4.8.2 with Visual Studio 2012 RC

 

I thought I’d put the just-released RC of Visual Studio 2012 through its paces by building my app. Of course, a prerequisite is getting Qt to build. Qt 4.8.2 builds fine with the earlier VC11 beta, so I thought it would be no problem. However, I run into this error when building QtWebKit (which my app requires):

  1. .\wtf/HashSet.h(180) : error C2664: 'std::pair<_Ty1,_Ty2>::pair(const std::pair<_Ty1,_Ty2> &)' : cannot convert parameter 1 from 'std::pair<_Ty1,_Ty2>' to 'const std::pair<_Ty1,_Ty2> &'
  2.         with
  3.         [
  4.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,
  5.             _Ty2=bool
  6.         ]
  7.         and
  8.         [
  9.             _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,
  10.             _Ty2=bool
  11.         ]
  12.         and
  13.         [
  14.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,
  15.             _Ty2=bool
  16.         ]
  17.         Reason: cannot convert from 'std::pair<_Ty1,_Ty2>' to 'const std::pair<_Ty1,_Ty2>'
  18.         with
  19.         [
  20.             _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,
  21.             _Ty2=bool
  22.         ]
  23.         and
  24.         [
  25.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,
  26.             _Ty2=bool
  27.         ]
  28.         No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
  29.         .\wtf/HashSet.h(179) : while compiling class template member function 'std::pair<_Ty1,_Ty2> WTF::HashSet<ValueArg>::add(void *const &)'
  30.         with
  31.         [
  32.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,
  33.             _Ty2=bool,
  34.             ValueArg=void *
  35.         ]
  36.         heap\MarkStack.h(195) : see reference to class template instantiation 'WTF::HashSet<ValueArg>' being compiled
  37.         with
  38.         [
  39.             ValueArg=void *
  40.         ]

HashSet.h line 180 is the return statement below.
  1. template<typename T, typename U, typename V>
  2. inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
  3. {
  4.     return m_impl.add(value);
  5. }

Which I believe is a call to this method:
  1. pair<iterator, bool> add(const ValueType& value) { return add<KeyType, ValueType, IdentityTranslatorType>(Extractor::extract(value), value); }

I can’t see how to change the code to get the compiler to accept it. Any ideas?

15 replies

June 5, 2012

alzi alzi
Lab Rat
1 posts

Hi bmedina,

I just had the same error when trying to compile Qt with VS2012 RC.
I noticed that the problem was about the return type of the add function and more specific it was that the first parameter of the returning pair was slitly different in the HashSet::add than in the HashTable::add.

So I tried to convert the the first parameter of the pair. Long story short here are the changes I made to make it work (in HashSet.h)

  1. template<typename T, typename U, typename V>
  2. inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
  3. {
  4.     typedef typename HashSet<T, U, V>::iterator iter_type;
  5.     auto& temp = m_impl.add(value);
  6.     return make_pair((iter_type)temp.first, temp.second);
  7. }

And the function just below the add function:

  1. template<typename Value, typename HashFunctions, typename Traits>
  2. template<typename T, typename HashTranslator>
  3. inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
  4. HashSet<Value, HashFunctions, Traits>::add(const T& value)
  5. {
  6.     typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
  7.     typedef typename HashSet<Value, HashFunctions, Traits>::iterator iter_type;
  8.     auto& temp = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
  9.     return make_pair((iter_type)temp.first, temp.second);
  10. }

I’m not quite sure whether this has any bad side effects since I did not dig any deeper into the different iterators types that will now be converted so I will give no guarantee that the code does the right thing after compiling ;)

June 6, 2012

bmedina bmedina
Lab Rat
2 posts

Thanks for the help! That got me compiling, and webkit seems to work okay. I don’t need this for production work, so I’m not too concerned about it for now.

June 8, 2012

patrick_g patrick_g
Lab Rat
1 posts

Seems that the problem is corrected by explicitly constructing the iterators in the pairs. Not sure why they stopped working. Some change in the standard? FWIW, I fixed it as follows (beware typos! I had to type it by hand):

  1. template<typename T, typename U, typename V>
  2. inline pair<typename HashSet<T,U,V>::const_iterator, bool> HashSet<T,U,V>::add(const ValueType &value)
  3. {
  4.     auto p= m_impl.add(value);
  5.     return make_pair(typename HashSet<T,U,V>::const_iterator(p.first), p.second);
  6. }
  7.  
  8. template<typename Value, typename HashFunctions, typename Traits>
  9. template<typename T, typename HashTranslator>
  10. inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
  11. HasSet<Value, HashFunctions, Traits>::add(const T& value)
  12. {
  13.     typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
  14.     auto p = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
  15.     return make_pair(typename HashSet<Value, HashFunctions, Traits>::iterator(p.first), p.second);
  16. }

June 12, 2012

Nosf Nosf
Lab Rat
60 posts

Am in two minds about which fix to pick. Guess both solve this issue currently, however I see in

patrick_g ‘s fix

  1. inline pair<typename HashSet<T,U,V>::const_iterator, bool> HashSet<T,U,V>::add(const ValueType

while the first fix has the original format of just iterator than HashSet<T,U,V>::const_iterator

Does this not matter?

September 5, 2012

FloGe FloGe
Lab Rat
14 posts

I’m using alzi’s fix to compile Qt 4.8.2 with Visual Studio 2012 RTM. It works so far, thanks!

September 28, 2012

paolo_dc paolo_dc
Lab Rat
3 posts

Hello,
A little up to this post.
I’ve followed http://rritw.com/a/JAVAbiancheng/ANT/20120630/178737.html post to compile Qt 4.8.2 for visual studio 2012.
At step 6, we have to deal with the error in wtf/hashset.h. I fixed it as alzi said. But I can’t still compile qt. I have still this error :(

  1. .\wtf/HashSet.h(180) : error C2664: 'std::pair<_Ty1,_Ty2>::pair(const std::pair<
  2. _Ty1,_Ty2> &)' : impossible de convertir le paramètre 1 de 'std::pair<_Ty1,_Ty2>
  3. ' en 'const std::pair<_Ty1,_Ty2> &'
  4.         with
  5.         [
  6.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
  7. ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
  8. ::HashTraits<void *>>,void *>,
  9.             _Ty2=bool
  10.         ]
  11.         and
  12.         [
  13.             _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<voi
  14. d *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF::HashTraits<void *>>,
  15.             _Ty2=bool
  16.         ]
  17.         and
  18.         [
  19.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
  20. ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
  21. ::HashTraits<void *>>,void *>,
  22.             _Ty2=bool
  23.         ]
  24.         Raison : impossible de convertir de 'std::pair<_Ty1,_Ty2>' en 'const std
  25. ::pair<_Ty1,_Ty2>'
  26.         with
  27.         [
  28.             _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<voi
  29. d *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF::HashTraits<void *>>,
  30.             _Ty2=bool
  31.         ]
  32.         and
  33.         [
  34.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
  35. ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
  36. ::HashTraits<void *>>,void *>,
  37.             _Ty2=bool
  38.         ]
  39.         Aucun opérateur de conversion définie par l'utilisateur disponible qui p
  40. uisse effectuer cette conversion, ou l'opérateur ne peut pas être appelé
  41.         .\wtf/HashSet.h(179) : lors de la compilation de la fonction membre 'std
  42. ::pair<_Ty1,_Ty2> WTF::HashSet<ValueArg>::add(void *const &)' de la classe modèl
  43. e
  44.         with
  45.         [
  46.             _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
  47. ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
  48. ::HashTraits<void *>>,void *>,
  49.             _Ty2=bool,
  50.             ValueArg=void *
  51.         ]
  52.         heap\MarkStack.h(74) : voir la référence à l'instanciation de la fonctio
  53. n modèle 'std::pair<_Ty1,_Ty2> WTF::HashSet<ValueArg>::add(void *const &)' en co
  54. urs de compilation
  55.        with
  56.        [
  57.            _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
  58. ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
  59. ::HashTraits<void *>>,void *>,
  60.            _Ty2=bool,
  61.            ValueArg=void *
  62.        ]
  63.        heap\MarkStack.h(195) : voir la référence à l'instanciation de la classe
  64.  modèle 'WTF::HashSet<ValueArg>' en cours de compilation
  65.         with
  66.         [
  67.             ValueArg=void *
  68.         ]
  69. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
  70. \VC\BIN\cl.EXE"' : code retour '0x2'
  71. Stop.
  72. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
  73. \VC\BIN\nmake.exe"' : code retour '0x2'
  74. Stop.
  75. NMAKE : fatal error U1077: 'cd' : code retour '0x2'
  76. Stop.
  77. NMAKE : fatal error U1077: 'cd' : code retour '0x2'
  78. Stop.

My hashset.h modification are :

  1.  template<typename T, typename U, typename V>
  2.     inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
  3.     {
  4.         typedef typename HashSet<T, U, V>::iterator iter_type;
  5.         auto& temp = m_impl.add(value);
  6.         return make_pair((iter_type)temp.first, temp.second);
  7.     }
  8.  
  9.  
  10.     template<typename Value, typename HashFunctions, typename Traits>
  11.     template<typename T, typename HashTranslator>
  12.     inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
  13.     HashSet<Value, HashFunctions, Traits>::add(const T& value)
  14.     {
  15.         typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
  16.         typedef typename HashSet<Value, HashFunctions, Traits>::iterator iter_type;
  17.         auto& temp = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
  18.         return make_pair((iter_type)temp.first, temp.second);
  19.     }

What am I doing wrong?
Can you help me please?

Paolo

October 3, 2012

FloGe FloGe
Lab Rat
14 posts

I posted it on PasteBin.

http://pastebin.com/kiXrcwx9

What you posted looked to me 100% like the same I have.

October 3, 2012

paolo_dc paolo_dc
Lab Rat
3 posts

Thanks Floge,

Yeah :( I don’t know why it doesn’t want to compile with me. I’ll try with your hashset.h.

October 3, 2012

paolo_dc paolo_dc
Lab Rat
3 posts

Ok, so I’ve still got this stupid error.
I can’t compile all the qt project with vs2012:/
I’ve configure the compiliation without the webtoolkit (I don’t need it in fact) and it works now

Thanks again Floge!

Paolo

November 5, 2012

FloGe FloGe
Lab Rat
14 posts

patrick_g’s patch also works with Qt 4.8.3, no idea why it isn’t “in” yet tho

oh well, what to expect when there is still no official win32-msvc2012 target available, leave alone win32-msvc2012_xp

December 16, 2012

FloGe FloGe
Lab Rat
14 posts

Qt 4.8.4 now has an official win32-msvc2012 target.

But this fix has yet to be patched in.

December 23, 2012

lschlegel lschlegel
Lab Rat
1 posts

I had the same issue building Qt 4.8.4 on win32-msvc2012.

I would like to add to the discussion that there are actually two versions of the HashSet.h file:
The one that causes the problem is src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h.

The other version of the file is src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashSet.h. Its add methods look like this:

  1. template<typename T, typename U, typename V>
  2. pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
  3. {
  4.     pair<typename HashTable<T, T, IdentityExtractor<T>, U, V, V>::iterator, bool> p = m_impl.add(value);
  5.     typename HashSet<T, U, V>::iterator temp = p.first;
  6.     pair<typename HashSet<T, U, V>::iterator, bool> p2 = pair<typename HashSet<T, U, V>::iterator, bool>(temp, p.second);
  7. //  p2.first = p.first;
  8. //  p2.second = p.second;
  9.     return p2;
  10. }
  11.  
  12. template<typename Value, typename HashFunctions, typename Traits>
  13. template<typename T, typename HashTranslator>
  14. pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
  15. HashSet<Value, HashFunctions, Traits>::add(const T& value)
  16. {
  17.     typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
  18.     pair<typename HashTableType::iterator, bool> p = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
  19.     return pair<iterator, bool>(p.first, p.second);
  20. }

They were obviously taken from two different versions of the WebKit project.

February 18, 2013

justDance justDance
Lab Rat
26 posts

I followed http://stackoverflow.com/questions/12113400/compiling-qt-4-8-x-for-visual-studio-2012/14928303#14928303 to build Qt 4.8.4 specifically for VS2012, but got link error: qtmaind.lib(qtmain_win.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1600’ doesn’t match value ‘1700’ in main.obj

I tried two options:
1) use command
configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2012
and 2) Go to mkspecs\win32-msvc2010. Open qmake.conf and change:
QMAKE_COMPILER_DEFINES += _MSC_VER=1600 WIN32
to:
QMAKE_COMPILER_DEFINES += _MSC_VER=1700 WIN32
then use command configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2010
both gave me the same error.

I checked configure.cache under my qt folder, it is showing: -platform win32-msvc2012

Does anybody know what is wrong here? Thanks

February 20, 2013

FloGe FloGe
Lab Rat
14 posts

justDance wrote:
I followed http://stackoverflow.com/questions/12113400/compiling-qt-4-8-x-for-visual-studio-2012/14928303#14928303 to build Qt 4.8.4 specifically for VS2012, but got link error: qtmaind.lib(qtmain_win.obj) : error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1600’ doesn’t match value ‘1700’ in main.obj

I tried two options:
1) use command
configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2012
and 2) Go to mkspecs\win32-msvc2010. Open qmake.conf and change:
QMAKE_COMPILER_DEFINES += _MSC_VER=1600 WIN32
to:
QMAKE_COMPILER_DEFINES += _MSC_VER=1700 WIN32
then use command configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2010
both gave me the same error.

I checked configure.cache under my qt folder, it is showing: -platform win32-msvc2012

Does anybody know what is wrong here? Thanks

While figuring out the correct way to compile, you might have prematurely compiled some parts with the MSC 1600 settings (either a qtmain_win.cpp or a main.cpp).

Try the following:

nmake clean
nmake confclean

Decide whether you want to use the win32-msvc2012 or the modified win32-msvc2010 mkspec. Both should work, but you should pick only one.

Then check the mkspec file you want to use is set up correctly, run configure one time, then do an nmake.

Each time you want to change something with the configuration you should do an nmake clean & nmake confclean first, or to be absolutely safe, start each time from a fresh unpacked source zip.

April 30, 2013

cboos cboos
Lab Rat
3 posts

This problem (the original HashSet.h one) is tracked in QTBUG-28335 [bugreports.qt-project.org]

 
  ‹‹ Building Qt 4.8.2 without QML tooling plugins?      Qt Kubuntu + mySQL error ››

You must log in to post a reply. Not a member yet? Register here!