Building Qt - novatiraspol/HTTA2 GitHub Wiki

First you need to get a compiler that uses the GNU ld linker. The Oracle-supplied GCC does not satisfy this; I solved it building my own compiler. To build a compiler, we need a compiler, therefore the first step is installing the Oracle-supplied GCC (Sun Studio's cc would probably work, too, but that would mean an extra repository would have to be added):

# pkg install gcc-7 gnu-binutils

Then our custom GCC can be built:

$ curl -L http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz | gtar -xvJf -
$ cd gcc-9.2.0
$ mkdir build && cd build
$ ../configure --prefix=/frameworks/gcc --enable-languages=c,c++ --with-ld=/usr/bin/gld --with-as=/usr/bin/gas
$ gmake
$ gmake install

The next is the installation of Qt dependencies, which is again done using IPS, since the Oracle repo has everything we need:

# pkg install libpng libxcursor libxfixes libxcomposite libdrm fontconfig gperf bison flex pkg-config libxkbcommon libxcb xcb-util freetype-2

The next step is to download and build Qt Base 5.13. There will be some changes that have to be made in order for it to build properly.

$ curl -L https://download.qt.io/archive/qt/5.13/5.13.0/submodules/qtbase-everywhere-src-5.13.0.tar.xz | gtar xvJf -
$ cd qtbase-everywhere-src-5.13.0
$ mkdir build && cd build

Now a few modifications to qmake.conf have to be done. Open mkspecs/solaris-g++-64 and:

  1. Add "-Wl,-rpath-link,/lib/64,-rpath-link,/lib/amd64,-rpath-link,/usr/lib/64,-rpath-link,/usr/lib/amd64,-rpath-link,/usr/X11/lib/amd64" (without quotes) to QMAKE_LFLAGS to fix the (likely misconfigured) Oracle-supplied linker. Without this Qt will build without X11 support!
  2. Add this line to ensure that position independent code (PIC) is generated (otherwiser linking would fail): QMAKE_CFLAGS += -fPIC
  3. Replace QMAKE_LIBDIR_X11 and QMAKE_LIBDIR_OPENGL with /usr/X11/lib/amd64 (the original value is /usr/X11/lib/64, which does not exist on Solaris 11.4).

Now we are (almost) prepared for the build. Open src/corelib/global/qrandom.cpp and change this code (around line 333)

#  ifdef AT_BASE
    // present at least on the BSDs too, indicates the address of the loader
    ulong base = getauxval(AT_BASE); 
    if (base) 
        *end++ = foldPointer(base); // 11 

so the first line looks like this:

#  if defined(AT_BASE) && not(__sun)

This disables the code under it on Solaris, which does not have getauxval (this is a workaround, perhaps there is a better solution). Now you can (hopefully successfully) configure:

PATH=/frameworks/gcc/bin/:$PATH ../configure -platform nebula -prefix /frameworks/qt -qt-xcb -system-freetype -xkbcommon --no-feature-opengl --no-feature-vnc

Now you need to nuke the versioning in src/corelib/global/qversiontagging.cpp and src/corelib/global/qversiontagging.h, because it fails to link with it, and then add the input directory in the plugins.pro file in case we build with xkbcommon enabled (if you don't do it, it won't build xkbcommon support and the XCB plugin will complain).

Then you can build and install:

PATH=/frameworks/gcc/bin/:$PATH gmake
PATH=/frameworks/gcc/bin/:$PATH gmake install

Note: QtX11Extras, QtSvg and QtTools are also good to include to the package for the purpose of building LXQt.