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):

    @
    .\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> &'
    with
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHashJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue>,void *>,
    _Ty2=bool
    ]
    and
    [
    _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHashJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue>,
    _Ty2=bool
    ]
    and
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHashJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue>,void *>,
    _Ty2=bool
    ]
    Reason: cannot convert from 'std::pair<_Ty1,_Ty2>' to 'const std::pair<_Ty1,_Ty2>'
    with
    [
    _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHashJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue>,
    _Ty2=bool
    ]
    and
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHashJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue>,void *>,
    _Ty2=bool
    ]
    No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    .\wtf/HashSet.h(179) : while compiling class template member function 'std::pair<_Ty1,_Ty2> WTF::HashSet<ValueArg>::add(void *const &)'
    with
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHashJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue,WTF::HashTraitsJSC::EncodedJSValue>,void *>,
    _Ty2=bool,
    ValueArg=void *
    ]
    heap\MarkStack.h(195) : see reference to class template instantiation 'WTF::HashSet<ValueArg>' being compiled
    with
    [
    ValueArg=void *
    ]
    @
    HashSet.h line 180 is the return statement below.
    @
    template<typename T, typename U, typename V>
    inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
    {
    return m_impl.add(value);
    }
    @
    Which I believe is a call to this method:
    @
    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?



  • 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)

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

    And the function just below the add function:

    @
    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
    HashSet<Value, HashFunctions, Traits>::add(const T& value)
    {
    typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
    typedef typename HashSet<Value, HashFunctions, Traits>::iterator iter_type;
    auto& temp = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
    return make_pair((iter_type)temp.first, temp.second);
    }
    @

    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 ;)



  • 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.



  • 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):

    @template<typename T, typename U, typename V>
    inline pair<typename HashSet<T,U,V>::const_iterator, bool> HashSet<T,U,V>::add(const ValueType &value)
    {
    auto p= m_impl.add(value);
    return make_pair(typename HashSet<T,U,V>::const_iterator(p.first), p.second);
    }

    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
    HasSet<Value, HashFunctions, Traits>::add(const T& value)
    {
    typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
    auto p = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
    return make_pair(typename HashSet<Value, HashFunctions, Traits>::iterator(p.first), p.second);
    }@



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

    patrick_g 's fix

    @
    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?



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



  • 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 :(

    @.\wtf/HashSet.h(180) : error C2664: 'std::pair<_Ty1,_Ty2>::pair(const std::pair<
    _Ty1,_Ty2> &)' : impossible de convertir le paramètre 1 de 'std::pair<_Ty1,_Ty2>
    ' en 'const std::pair<_Ty1,_Ty2> &'
    with
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
    ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
    ::HashTraits<void *>>,void *>,
    _Ty2=bool
    ]
    and
    [
    _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<voi
    d *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF::HashTraits<void *>>,
    _Ty2=bool
    ]
    and
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
    ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
    ::HashTraits<void *>>,void *>,
    _Ty2=bool
    ]
    Raison : impossible de convertir de 'std::pair<_Ty1,_Ty2>' en 'const std
    ::pair<_Ty1,_Ty2>'
    with
    [
    _Ty1=WTF::HashTableIterator<void *,void *,WTF::IdentityExtractor<voi
    d *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF::HashTraits<void *>>,
    _Ty2=bool
    ]
    and
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
    ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
    ::HashTraits<void *>>,void *>,
    _Ty2=bool
    ]
    Aucun opérateur de conversion définie par l'utilisateur disponible qui p
    uisse effectuer cette conversion, ou l'opérateur ne peut pas être appelé
    .\wtf/HashSet.h(179) : lors de la compilation de la fonction membre 'std
    ::pair<_Ty1,_Ty2> WTF::HashSet<ValueArg>::add(void *const &)' de la classe modèl
    e
    with
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
    ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
    ::HashTraits<void *>>,void *>,
    _Ty2=bool,
    ValueArg=void *
    ]
    heap\MarkStack.h(74) : voir la référence à l'instanciation de la fonctio
    n modèle 'std::pair<_Ty1,_Ty2> WTF::HashSet<ValueArg>::add(void *const &)' en co
    urs de compilation
    with
    [
    _Ty1=WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *
    ,WTF::IdentityExtractor<void *>,WTF::PtrHash<void *>,WTF::HashTraits<void *>,WTF
    ::HashTraits<void *>>,void *>,
    _Ty2=bool,
    ValueArg=void *
    ]
    heap\MarkStack.h(195) : voir la référence à l'instanciation de la classe
    modèle 'WTF::HashSet<ValueArg>' en cours de compilation
    with
    [
    ValueArg=void *
    ]
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
    \VC\BIN\cl.EXE"' : code retour '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
    \VC\BIN\nmake.exe"' : code retour '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : code retour '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : code retour '0x2'
    Stop.@

    My hashset.h modification are :
    @ template<typename T, typename U, typename V>
    inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
    {
    typedef typename HashSet<T, U, V>::iterator iter_type;
    auto& temp = m_impl.add(value);
    return make_pair((iter_type)temp.first, temp.second);
    }

    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
    HashSet<Value, HashFunctions, Traits>::add(const T& value)
    {
        typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
        typedef typename HashSet<Value, HashFunctions, Traits>::iterator iter_type;
        auto& temp = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
        return make_pair((iter_type)temp.first, temp.second);
    }@
    

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

    Paolo



  • I posted it on PasteBin.

    http://pastebin.com/kiXrcwx9

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



  • Thanks Floge,

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



  • 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



  • 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



  • Qt 4.8.4 now has an official win32-msvc2012 target.

    But this fix has yet to be patched in.



  • 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:

    @
    template<typename T, typename U, typename V>
    pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
    {
    pair<typename HashTable<T, T, IdentityExtractor<T>, U, V, V>::iterator, bool> p = m_impl.add(value);
    typename HashSet<T, U, V>::iterator temp = p.first;
    pair<typename HashSet<T, U, V>::iterator, bool> p2 = pair<typename HashSet<T, U, V>::iterator, bool>(temp, p.second);
    // p2.first = p.first;
    // p2.second = p.second;
    return p2;
    }

    template<typename Value, typename HashFunctions, typename Traits>
    template<typename T, typename HashTranslator>
    pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
    HashSet<Value, HashFunctions, Traits>::add(const T& value)
    {
    typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
    pair<typename HashTableType::iterator, bool> p = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
    return pair<iterator, bool>(p.first, p.second);
    }
    @

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



  • 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



  • [quote author="justDance" date="1361163855"]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[/quote]

    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.



  • This problem (the original HashSet.h one) is tracked in "QTBUG-28335":https://bugreports.qt-project.org/browse/QTBUG-28335


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.