Sans Pareil Technologies, Inc.

Key To Your Business

Building Qt



We have compiled and used Qt using both Solaris Studio and GCC compiler suites. Accordingly instructions are provided for building using either compiler. Please note that we have so far succeeded in building Qt Creator only using GCC.
Solaris Studio 
These instructions apply for building version 4.8.4 of the Qt source distribution. We have not switched to Qt 5 yet, hence no instructions are provided at present for building Qt 5.

For Solaris Studio, a couple of source modifications are required to satisfy the more pedantic compiler. Edit the following files as specified before attempting to build the source distribution.

Edit src/corelib/arch/qatomic_x86_64.h and modify the following lines:

240 template <typename T>
241 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
242 {
243     return q_atomic_test_and_set_ptr(&_q_value, expectedValue, newValue);
244 }

to

240 template <typename T>
241 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
242 {
243     return q_atomic_test_and_set_ptr(&_q_value, (void*)expectedValue, (void*)newValue);
244 }

Without this modification, the following error will be reported by the compiler:

"../../include/QtCore/../../src/corelib/arch/qatomic_x86_64.h", line 243: Error: Formal argument expected of type void* in call to q_atomic_test_and_set_ptr(volatile void*, void*, void*) is being passed const QString*.
"qdbusintegrator.cpp", line 76:     Where: While instantiating "QBasicAtomicPointer<const QString>::testAndSetOrdered(const QString*, const QString*)".
"qdbusintegrator.cpp", line 76:     Where: Instantiated from non-template code.
"../../include/QtCore/../../src/corelib/arch/qatomic_x86_64.h", line 243: Error: Formal argument newval of type void* in call to q_atomic_test_and_set_ptr(volatile void*, void*, void*) is being passed const QString*.
"qdbusintegrator.cpp", line 76:     Where: While instantiating "QBasicAtomicPointer<const QString>::testAndSetOrdered(const QString*, const QString*)".
"qdbusintegrator.cpp", line 76:     Where: Instantiated from non-template code.

Edit src/gui/dialogs/qfiledialog.cpp and modify the following lines:

896 #if defined(Q_OS_SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L)
897         tmpPw = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize);
898 #else
899         err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw);
900 #endif

to

896 //#if defined(Q_OS_SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L)
897         //tmpPw = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize);
898 //#else
899         err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw);
900 //#endif

This conditional code seems to be for older versions of Solaris (probably up to Solaris 9) and is no longer needed (we are on Solaris 11). Without this modification the following error will be reported:

"dialogs/qfiledialog.cpp", line 897: Error: Too few arguments in call to "getpwnam_r(const char*, passwd*, char*, int, passwd**)".

Update the 64 bit compiler and linker flags in the mkspec file. The mkspec file shipped with the Qt sources is from a earlier version of the Solaris Studio compiler suite and is now deprecated (we use version 12.3).

Edit mkspecs/solaris-cc-64/qmake.conf and search and replace xarch=generic64 with m64.

The default configure script disables support for building QtConcurrent and QtXmlPatterns modules (compiling WebKit using Solaris Studio is still not possible). With the current Solaris Studio compiler suite these modules do build, hence we modify the configure script to enable building those as well. Edit the configure script and modify the canBuildXxx configuration as follows:

7680     solaris-cc*)
7681         # Check the compiler version
7682         case `${QMAKE_CONF_COMPILER} -V 2>&1 | awk '{print $4}'` in
7683             5.[012345678])
7684                 canBuildWebKit="no"
7685                 canBuildQtXmlPatterns="no"
7686                 canBuildQtConcurrent="no"
7687                 ;;
7688             5.*)
7689                 canBuildWebKit="no"
7690                 canBuildQtConcurrent="no"
7691                 ;;
7692         esac
7693         ;;

to

7680     solaris-cc*)
7681         # Check the compiler version
7682         case `${QMAKE_CONF_COMPILER} -V 2>&1 | awk '{print $4}'` in
7683             5.[012345678])
7684                 canBuildWebKit="no"
7685                 canBuildQtXmlPatterns="yes"
7686                 canBuildQtConcurrent="yes"
7687                 ;;
7688             5.*)
7689                 canBuildWebKit="no"
7690                 canBuildQtConcurrent="yes"
7691                 ;;
7692         esac
7693         ;;

With these modifications in place, you can configure and build Qt. A sample shell script we use to compile and install Qt is as follows:

#!/bin/ksh

./configure -opensource --prefix=/opt/qt -optimized-qmake -no-qt3support \
    -nomake examples -nomake demos -nomake docs -nomake translations \
    -platform solaris-cc-64-stlport
gmake -j8

if [ $? -eq 0 ]
then
  pfexec gmake install
fi

Note that Qt does not require stlport, however most other third party tools we use (Poco, Xapian, …) require stlport, hence we use the same with Qt.

GCC 

Since we use GCC 4.7.1 from opencsw instead of the GCC 3.4 distributed along with Solaris we need to modify the mkspecs files accordingly.

vi mkspecs/solaris-g++-64/qmake.conf

     45 QMAKE_INCDIR            = /opt/csw/include
     46 QMAKE_LIBDIR            = /opt/csw/lib/64
     58 QMAKE_LFLAGS            = -R/opt/csw/lib/64

Note that you may chose to use crle to permanently set the library path to /opt/csw/lib/64 instead of using Rpath in the mkspecs file.

The following script was used to compile Qt 4.8.4 using GCC 4.7.1

#!/bin/ksh

./configure -opensource --prefix=/usr/local/qt -optimized-qmake -no-qt3support \
  -nomake examples -nomake demos -nomake docs -nomake translations \
  -platform solaris-g++-64
gmake -s -j8
pfexec gmake install
Qmake projects are our standard for building C++ projects (regardless of whether the project uses Qt or not). We have used Qt Core and qmake successfully on numerous internal C++ projects.