How to compile QtWebKit for Qt5.6 on Ubuntu22

Viewed 27

I am migrating my application from Qt4.8 to Qt 5.6 so I need to manually compile QtWebKit like documentation said:

With Qt 5.6 the following modules are no longer part of the release packages, but users can still build them from source:
- Qt WebKit
- Qt Declarative (Qt Quick 1)

So i did:

  1. git clone --branch 5.6 git://code.qt.io/qt/qtwebkit.git
  2. cd qtwebkit
  3. mkdir build && cd build
  4. /home/john/Qt5.6.3/5.6.3/gcc_64/bin/qmake ../WebKit.pro
  5. make

But I got error:

home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp: In function ‘OpaqueJSString* JSStringCreateWithCharacters(const JSChar*, size_t)’:
/home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp:40:35: error: invalid conversion from ‘const JSChar*’ {aka ‘const short unsigned int*’} to ‘const UChar*’ {aka ‘const char16_t*’} [-fpermissive]
   40 |     return OpaqueJSString::create(chars, numChars).leakRef();
      |                                   ^~~~~
          |                                   |
      |                                   const JSChar* {aka const short unsigned int*}
In file included from /home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp:31:
/home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/OpaqueJSString.h:49:59: note:   initializing argument 1 of ‘static WTF::PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UChar*, unsigned int)’
   49 |     static PassRefPtr<OpaqueJSString> create(const UChar* characters, unsigned length)
      |                                              ~~~~~~~~~~~~~^~~~~~~~~~
/home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp: In function ‘OpaqueJSString* JSStringCreateWithCharactersNoCopy(const JSChar*, size_t)’:
/home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp:65:68: error: invalid conversion from ‘const JSChar*’ {aka ‘const short unsigned int*’} to ‘const UChar*’ {aka ‘const char16_t*’} [-fpermissive]
   65 |     return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars, WTF::DoesNotHaveTerminatingNullCharacter)).leakRef();
      |                                                                    ^~~~~
      |                                                                    |
      |                                                                    const JSChar* {aka const short unsigned int*}
In file included from /home/john/Qt5.6.3/qtwebkit/Source/WTF/wtf/text/WTFString.h:29,
                 from /home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/OpaqueJSString.h:30,
                 from /home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp:31:
/home/john/Qt5.6.3/qtwebkit/Source/WTF/wtf/text/StringImpl.h:431:91: note:   initializing argument 1 of ‘static WTF::PassRefPtr<WTF::StringImpl> WTF::StringImpl::createWithoutCopying(const UChar*, unsigned int, WTF::HasTerminatingNullCharacter)’
  431 |     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const UChar* characters, unsigned length, HasTerminatingNullCharacter);
      |                                                                              ~~~~~~~~~~~~~^~~~~~~~~~
/home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp: In function ‘const JSChar* JSStringGetCharactersPtr(JSStringRef)’:
/home/john/Qt5.6.3/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp:86:30: error: invalid conversion from ‘const UChar*’ {aka ‘const char16_t*’} to ‘const JSChar*’ {aka ‘const short unsigned int*’} [-fpermissive]
   86 |     return string->characters();
      |            ~~~~~~~~~~~~~~~~~~^~
      |                              |
      |                              const UChar* {aka const char16_t*}
make[2]: *** [Makefile.JavaScriptCore.Target:4756: .obj/API/JSStringRef.o] Error 1
make[2]: Leaving directory '/home/john/Qt5.6.3/qtwebkit/build/Source/JavaScriptCore'
make[1]: *** [Makefile.JavaScriptCore:98: sub-Target-pri-make_first-ordered] Error 2
make[1]: Leaving directory '/home/john/Qt5.6.3/qtwebkit/build/Source/JavaScriptCore'
make: *** [Makefile:94: sub-Source-JavaScriptCore-JavaScriptCore-pro-make_first-ordered] Error 2

I tried fix that by use patch like below but it didn't help me:

diff --git a/Source/WTF/wtf/Compiler.h b/Source/WTF/wtf/Compiler.h
index ead844f..e62cfd4 100644
--- a/Source/WTF/wtf/Compiler.h
+++ b/Source/WTF/wtf/Compiler.h
@@ -61,6 +61,7 @@
 #define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_feature(has_trivial_destructor)
 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_feature(cxx_strong_enums)
 #define WTF_COMPILER_SUPPORTS_CXX_REFERENCE_QUALIFIED_FUNCTIONS __has_feature(cxx_reference_qualified_functions)
+#define WTF_COMPILER_SUPPORTS_CXX_NEW_CHAR_TYPES !defined(_LIBCPP_HAS_NO_UNICODE_CHARS)
 #endif
@@ -142,6 +143,7 @@
 #define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1
 #endif
 #if GCC_VERSION_AT_LEAST(4, 5, 0)
+#define WTF_COMPILER_SUPPORTS_CXX_NEW_CHAR_TYPES 1
 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1
 #endif
 #if GCC_VERSION_AT_LEAST(4, 6, 0)

diff --git a/Source/WTF/wtf/TypeTraits.h b/Source/WTF/wtf/TypeTraits.h
index b9e46bc..876fa45 100644
--- a/Source/WTF/wtf/TypeTraits.h
+++ b/Source/WTF/wtf/TypeTraits.h
@@ -75,6 +75,10 @@ namespace WTF {
 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
     template<> struct IsInteger<wchar_t>            { static const bool value = true; };
 #endif
+#if COMPILER_SUPPORTS(CXX_NEW_CHAR_TYPES)
+    template<> struct IsInteger<char16_t>           { static const bool value = true; };
+    template<> struct IsInteger<char32_t>           { static const bool value = true; };
+#endif

     template<typename T> struct IsFloatingPoint     { static const bool value = false; };
     template<> struct IsFloatingPoint<float>        { static const bool value = true; };

What could I do to compile that module?

0 Answers
Related