Qt 4.8, Visual Studio 2013 compiling error

11,531

Solution 1

To fix 'round' and 'roundf' errors replace (lines 103 and 110):

static double round(double num)
static float roundf(float num)

with:

static inline double round(double num)
static inline float roundf(float num)

To fix 'signbit' error enclose it with following macro (line 128):

#if _MSC_VER < 1800
inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
#endif

Solution 2

Use the official patch for VS 2013 compatibility.

Solution 3

Have you run "vcvars32.bat" before compiling? It seems the environment variables of VC++ are not appropriately set.

See http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx for informations about the environment of VC++.

bye

Solution 4

Your problem is that you do not use Visual Studio 2012 but 2013. VS 2012 is VS11 while VS 2013 is VS12 and your path "C:\Program Files (x86)\Microsoft Visual Studio 12.0" belongs to VS 2013.

The core problem however is that VS 2013 is C99 compliant which causes problems in the V8 engine and javascriptcore.

There is currently no solution but manual patching.

Solution 5

The two patches proposed above were not enough. In my case, after applying them to Qt 4.8.5 I got another error:

HashSet.h(180) : error C2664: 'std::pair<WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JS
C::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,bool>::pair(const std::pair<WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::P
trHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,bool> &)' : cannot convert argument 1 from 'std::pair<WTF::HashTableIterator<Key,Va
lue,Extractor,HashFunctions,Traits,KeyTraits>,bool>' to 'const std::pair<WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJ
SValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,bool> &'                                                                                               
        with                                                                                                                                                                                      
        [                                                                                                                                                                                         
            Key=void *                                                                                                                                                                            
,            Value=void *                                                                                                                                                                         
,            Extractor=WTF::IdentityExtractor<void *>                                                                                                                                             
,            HashFunctions=WTF::PtrHash<JSC::EncodedJSValue>                                                                                                                                      
,            Traits=WTF::HashTraits<JSC::EncodedJSValue>                                                                                                                                          
,            KeyTraits=WTF::HashTraits<JSC::EncodedJSValue>                                                                                                                                       
        ]                                                                                                                                                                                         
        Reason: cannot convert from 'std::pair<WTF::HashTableIterator<Key,Value,Extractor,HashFunctions,Traits,KeyTraits>,bool>' to 'const std::pair<WTF::HashTableConstIteratorAdapter<WTF::HashT
able<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,bool>'                     
        with                                                                                                                                                                                      
        [                                                                                                                                                                                         
            Key=void *                                                                                                                                                                            
,            Value=void *                                                                                                                                                                         
,            Extractor=WTF::IdentityExtractor<void *>                                                                                                                                             
,            HashFunctions=WTF::PtrHash<JSC::EncodedJSValue>                                                                                                                                      
,            Traits=WTF::HashTraits<JSC::EncodedJSValue>                                                                                                                                          
,            KeyTraits=WTF::HashTraits<JSC::EncodedJSValue>                                                                                                                                       
        ]                                                                                                                                                                                         
        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<WTF::HashTableConstIteratorAdapter<WTF::HashTable<void *,void *,WTF::IdentityExtractor<void *>,WTF::PtrHa
sh<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>,WTF::HashTraits<JSC::EncodedJSValue>>,void *>,bool> WTF::HashSet<void *,WTF::PtrHash<JSC::EncodedJSValue>,WTF::HashTraits<JSC::Encode
dJSValue>>::add(void *const &)'                                                                                                                                                                   

Solution was to grab 3 files from Git Qt4 repository:

/src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h https://qt.gitorious.org/qt/mi-clone/raw/b45cc6bba9f85497eedf10cb5969d24273cb11db:src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h

/src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h https://qt.gitorious.org/qt/mi-clone/raw/b45cc6bba9f85497eedf10cb5969d24273cb11db:src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h

/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h https://qt.gitorious.org/qt/mi-clone/raw/b45cc6bba9f85497eedf10cb5969d24273cb11db:src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h

Share:
11,531
Sidux
Author by

Sidux

Am student and developer, a passionate of technologies and interested in artificial intelligence and logical constraint programming.

Updated on July 22, 2022

Comments

  • Sidux
    Sidux almost 2 years

    Am folowing this tutorial to compile Qt 4.8 with visual Studio 2013 but after running nmake i get:

    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSCallbackConstructor.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSCallbackFunction.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSCallbackObject.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSClassRef.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSContextRef.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSObjectRef.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    JSStringRef.cpp
    JSValueRef.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    OpaqueJSString.cpp
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(103) : error C2491: 'round' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(110) : error C2491: 'roundf' : definition of dllimport function not allowed
    C:\Qt\4.8.5.src\src\3rdparty\javascriptcore\JavaScriptCore\wtf/MathExtras.h(128) : error C2084: function 'bool signbit(double)' already has a body
            C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(324) : see previous definition of 'signbit'
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(615) : error C2264: 'signbit' : error in function definition or declaration; function not called
    c:\qt\4.8.5.src\src\3rdparty\javascriptcore\javascriptcore\runtime\JSValue.h(696) : error C2264: 'signbit' : error in function definition or declaration; function not called
    Generating Code...
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\cl.EXE"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    

    Thanks for any help

  • Roeland
    Roeland over 10 years
    Better yet, use the official patch.
  • Zdenik
    Zdenik over 10 years
    The full patch is here
  • barbara.post
    barbara.post about 10 years
    For clarity, I relink the proposed patches in question comments: qt.gitorious.org/qt/qtscript/commit/… and qt.gitorious.org/qt/qtdeclarative/commit/…
  • Nil
    Nil over 9 years
    I tested both patches from JPaget and Zdenik and they don't work in Qt 4.8.6. This is the only working answer.
  • x y
    x y over 8 years
    Since the gitorious site with patches is offline for days (migrating stuff), can someone please send me the patched file for /src/3rdparty/**webkit**/Source/JavaScriptCore/wtf/HashSet.h‌​, since this bug is still not fixed in qt 4.8.6 (allthough /src/3rdparty/**javascriptcore**/JavaScriptCore/wtf/HashSet.‌​h compiles). Thanksalot, Hermann
  • N0dGrand87
    N0dGrand87 about 7 years
    Based on extended C99 library in VS2013 - see article C99 library support in Visual Studio 2013 enclose old implementation with code: #if _MSC_VER < 1800 ... #endif