Qt页面未列出Solaris的预编译Qt 5软件包。搜索,它似乎也没有包含在流行的软件包存储库OpenCSW中。一些谷歌点击建议在Solaris下构建Qt 5涉及Solaris 10下的一些工作。
因此我的问题:如何在Solaris 10下构建Qt 5.2?
答案 0 :(得分:9)
基本上是:
cd qt-everywhere-opensource-src-5.2.0
./configure -prefix $MY_PREFIX -opensource -confirm-license -nomake tests \
-R /opt/csw/lib/64 -R /opt/csw/X11/lib/64 -qt-xcb -platform solaris-g++-64 \
-verbose
gmake -j16
gmake -j16 install
加上一些调整,因为似乎没有使用Qt 5 Solaris很多,但是。
wget http://download.qt-project.org/official_releases/qt/5.2/5.2.0/single/qt-everywhere-opensource-src-5.2.0.tar.gz
md5sum qt-everywhere-opensource-src-5.2.0.tar.gz
228b6384dfd7272de00fd8b2c144fecd qt-everywhere-opensource-src-5.2.0.tar.gz
如果系统不适合md5sum
,您可以使用openssl md5 filename
。
我建议使用OpenCSW因为我们需要一些依赖来构建Qt。最重要的是:
CSWlibxcbdevel
CSWlibicu-dev # soft-dependency
CSWgcc4g++
CSWgmake
我建议使用GCC编译Qt。我不知道使用Solaris Studio中的C ++编译器有什么好处。相反,对于许多用例,此编译器的C ++ / STL支持级别可能不足。
确保您的环境干净。这意味着/opt/csw/bin
首先出现,并且没有设置LD_LIBRAYR_PATH *变量。
为简化起见,可能会从PATH
中删除某些目录。例如,不会意外地拾取Solaris Studio安装中的cc
,CC
命令(例如,在编译捆绑的第三方组件期间。
/usr/sfw
下的软件太过时了。来自OpenCSW的/opt/csw
是更好的替代品。然后,X-Open版本不足以用于某些使用过的系统功能。
--- a/qtbase/mkspecs/solaris-g++-64/qmake.conf
+++ b/qtbase/mkspecs/solaris-g++-64/qmake.conf
@@ -35,7 +35,7 @@ QMAKE_LEX = flex
QMAKE_LEXFLAGS =
QMAKE_YACC = yacc
QMAKE_YACCFLAGS = -d
-QMAKE_CFLAGS = -m64 -D_XOPEN_SOURCE=500 -D__EXTENSIONS__
+QMAKE_CFLAGS = -m64 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__
QMAKE_CFLAGS_DEPS = -M
QMAKE_CFLAGS_WARN_ON = -Wall -W
QMAKE_CFLAGS_WARN_OFF = -w
@@ -58,8 +58,8 @@ QMAKE_CXXFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_STATIC_LIB
QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
-QMAKE_INCDIR = /usr/sfw/include
-QMAKE_LIBDIR = /usr/sfw/lib/64
+QMAKE_INCDIR = /opt/csw/include /opt/csw/X11/include
+QMAKE_LIBDIR = /opt/csw/lib/64 /opt/csw/X11/lib/64
QMAKE_INCDIR_X11 = /usr/openwin/include
QMAKE_LIBDIR_X11 = /usr/openwin/lib/64
QMAKE_INCDIR_OPENGL = /usr/openwin/include
Solaris附带了/bin/sh
违反POSIX的延伸
Qt在qmake生成的配置脚本甚至shell代码
代码失败。
POSIX没有指定/bin/sh
必须符合它只是指定系统必须具有符合标准的shell可用的地方'。在Solaris上它是例如在/usr/xpg4/bin/sh
下。获得符合shell的可移植方法是在getconf CS_PATH
...
无论如何,我对Solaris的选择只是使用/usr/bin/bash
:
无论如何,我对Solaris的选择只是使用/usr/bin/bash
:
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/usr/bin/bash
#############################################################################
##
## Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
--- a/qtbase/configure
+++ b/qtbase/configure
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/bash
#############################################################################
##
## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
@@ -6892,7 +6892,7 @@ fi'`
echo "$CONFIG_STATUS" | grep '\-confirm\-license' >/dev/null 2>&1 || CONFIG_STATUS="$CONFIG_STATUS -confirm-license"
[ -f "$outpath/config.status" ] && rm -f "$outpath/config.status"
- echo "#!/bin/sh" > "$outpath/config.status"
+ echo "#!/usr/bin/bash" > "$outpath/config.status"
[ -n "$PKG_CONFIG_SYSROOT_DIR" ] && \
echo "export PKG_CONFIG_SYSROOT_DIR=$PKG_CONFIG_SYSROOT_DIR" >> "$outpath/config.status"
[ -n "$PKG_CONFIG_LIBDIR" ] && \
--- a/qtbase/qmake/generators/makefile.cpp
+++ b/qtbase/qmake/generators/makefile.cpp
@@ -2306,6 +2306,10 @@ MakefileGenerator::writeHeader(QTextStream &t)
if (ofile.lastIndexOf(Option::dir_sep) != -1)
ofile.remove(0, ofile.lastIndexOf(Option::dir_sep) +1);
t << "MAKEFILE = " << ofile << endl << endl;
+
+ t << "# custom mod because Solaris /bin/sh is such a standard-violating choice\n"
+ << "# - gs, 2013-12-23" << endl;
+ t << "SHELL = /usr/bin/bash" << endl << endl;
}
QList<MakefileGenerator::SubTarget*>
Solaris 10附带了一个过时的libicu - 缺少Qt 5需要的功能。因此,我们只是扩展了icu-test。如果我们安装了最近的libicu,那么要么没有构建ICU支持,要么没有正确的支持。通过OpenCSW。
--- a/qtbase/config.tests/unix/icu/icu.cpp
+++ b/qtbase/config.tests/unix/icu/icu.cpp
@@ -43,6 +43,16 @@
#include <unicode/ucol.h>
#include <unicode/ustring.h>
+// for testing if ucal_clone is there (i.e. if we have libicu >= 4.0)
+#include <unicode/ucal.h>
+
+static UCalendar *ucp(UCalendar *i)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *r = ucal_clone(i, &status);
+ return r;
+}
+
int main(int, char **)
{
UErrorCode status = U_ZERO_ERROR;
@@ -50,5 +60,10 @@ int main(int, char **)
if (U_FAILURE(status))
return 0;
ucol_close(collator);
+
+ UCalendar *cal = ucal_open(0, -1, "C", UCAL_GREGORIAN, &status);
+ UCalendar *x = ucp(cal);
+ ucal_close(x);
+
return 0;
}
或许可以通过OpenCSW安装libpcre。
--- a/qtbase/src/3rdparty/pcre/pcre_compile.c
+++ b/qtbase/src/3rdparty/pcre/pcre_compile.c
@@ -66,6 +66,8 @@ COMPILE_PCREx macro will already be appropriately set. */
#endif
+#include <stdint.h>
+
/* Macro for setting individual bits in class bitmaps. */
#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
至少在Solaris 10 / Sparc上,代码使用了函数fromBytesToWord
和fromWordtoBytes
,因此:
--- a/qtbase/src/3rdparty/sha3/KeccakF-1600-opt64.c
+++ b/qtbase/src/3rdparty/sha3/KeccakF-1600-opt64.c
@@ -324,7 +324,7 @@ static void KeccakPermutation(unsigned char *state)
KeccakPermutationOnWords((UINT64*)state);
}
-#if 0 // Unused in the Qt configuration
+#if 1 // Unused in the Qt configuration
static void fromBytesToWord(UINT64 *word, const UINT8 *bytes)
{
unsigned int i;
@@ -445,7 +445,7 @@ static void KeccakAbsorb(unsigned char *state, const unsigned char *data, unsign
#endif
}
-#if 0 // Unused in the Qt configuration
+#if 1 // Unused in the Qt configuration
static void fromWordToBytes(UINT8 *bytes, const UINT64 word)
{
unsigned int i;
uname()
函数通过Solaris上的CPP构造激活
并在该标题中声明:
--- a/qtbase/src/corelib/io/qfileselector.cpp
+++ b/qtbase/src/corelib/io/qfileselector.cpp
@@ -51,6 +51,8 @@
#include <QtCore/QLocale>
#include <QtCore/QDebug>
+#include <sys/utsname.h>
+
QT_BEGIN_NAMESPACE
//Environment variable to allow tooling full control of file selectors
在Solaris下,父代码在该代码路径中未使用,代码将使用-Werror
...
--- a/qtbase/src/corelib/io/qfilesystemwatcher.cpp
+++ b/qtbase/src/corelib/io/qfilesystemwatcher.cpp
@@ -77,6 +77,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
return QKqueueFileSystemWatcherEngine::create(parent);
#else
+ (void)parent;
return 0;
#endif
}
在Solaris uid_t
下有一个意想不到的&#39;标志( - &gt; Werror)。将其投射到ssize_t
应该是一个便携且安全的选择:
--- a/qtbase/src/corelib/io/qstandardpaths_unix.cpp
+++ b/qtbase/src/corelib/io/qstandardpaths_unix.cpp
@@ -132,7 +132,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
// "The directory MUST be owned by the user"
QFileInfo fileInfo(xdgRuntimeDir);
- if (fileInfo.ownerId() != myUid) {
+ if (fileInfo.ownerId() != ssize_t(myUid)) {
qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir),
fileInfo.ownerId(), myUid);
return QString();
与线程代码类似的问题(由于指针转换中的符号不匹配而导致错误)。施放到size_t应该是一个便携式安全选择:
--- a/qtbase/src/corelib/thread/qthread_unix.cpp
+++ b/qtbase/src/corelib/thread/qthread_unix.cpp
@@ -231,7 +231,7 @@ QThreadData *QThreadData::current()
}
data->deref();
data->isAdopted = true;
- data->threadId = (Qt::HANDLE)pthread_self();
+ data->threadId = (Qt::HANDLE)((size_t)pthread_self());
if (!QCoreApplicationPrivate::theMainThread)
QCoreApplicationPrivate::theMainThread = data->thread;
}
@@ -314,7 +314,7 @@ void *QThreadPrivate::start(void *arg)
thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
}
- data->threadId = (Qt::HANDLE)pthread_self();
+ data->threadId = (Qt::HANDLE)((size_t)pthread_self());
set_thread_data(data);
data->ref();
@@ -393,7 +393,7 @@ void QThreadPrivate::finish(void *arg)
Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
{
// requires a C cast here otherwise we run into trouble on AIX
- return (Qt::HANDLE)pthread_self();
+ return (Qt::HANDLE)((size_t)pthread_self());
}
#if defined(QT_LINUXBASE) && !defined(_SC_NPROCESSORS_ONLN)
struct in_addr
在Solaris上有一个struct作为第一个属性,因此在使用{0}
进行初始化时会向GCC发出警告 - 因此,在Qt-compile期间会产生错误:
--- a/qtbase/src/network/socket/qnativesocketengine_unix.cpp
+++ b/qtbase/src/network/socket/qnativesocketengine_unix.cpp
@@ -63,6 +63,7 @@
#endif
#include <netinet/tcp.h>
+#include <string.h>
QT_BEGIN_NAMESPACE
@@ -737,7 +738,8 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
return QNetworkInterface::interfaceFromIndex(v);
}
- struct in_addr v = { 0 };
+ struct in_addr v;
+ memset(&v, 0, sizeof(struct in_addr));
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
if (::getsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, &sizeofv) == -1)
return QNetworkInterface();
X11/Xutil.h
的标题注释列出X11/Xutil.h
作为依赖关系,实际上,如果没有包含某些声明,Solaris下将缺少这些声明。
--- a/qtbase/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/qtbase/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -46,6 +46,7 @@
#include <QtCore/QBuffer>
#include <qdebug.h>
+#include <X11/Xlib.h>
#include <X11/Xutil.h>
#undef XCB_ATOM_STRING
X11/extensions/XIproto.h
不是C ++ - 在Solaris下是安全的。这意味着它包含结构成员名称class
。幸运的是,该代码中似乎没有使用标题。
--- a/qtbase/src/plugins/platforms/xcb/qxcbxsettings.cpp
+++ b/qtbase/src/plugins/platforms/xcb/qxcbxsettings.cpp
@@ -43,7 +43,7 @@
#include <QtCore/QByteArray>
-#include <X11/extensions/XIproto.h>
+//#include <X11/extensions/XIproto.h>
QT_BEGIN_NAMESPACE
/* Implementation of http://standards.freedesktop.org/xsettings-spec/xsettings-0.5.html */
pow()
函数有一些过载,如C ++标准中所规定的那样,它引入了Solaris下的歧义。修复这样的类型应该是便携和安全的:
--- a/qtdeclarative/src/qml/jsruntime/qv4globalobject.cpp
+++ b/qtdeclarative/src/qml/jsruntime/qv4globalobject.cpp
@@ -534,7 +534,7 @@ ReturnedValue GlobalFunctions::method_parseInt(CallContext *ctx)
}
if (overflow) {
- double result = (double) v_overflow * pow(R, overflow_digit_count);
+ double result = (double) v_overflow * pow(double(R), int(overflow_digit_count));
result += v;
return Encode(sign * result);
} else {
在Solaris下,alloca需要另一个标头:
--- a/qtdeclarative/src/qml/jsruntime/qv4stringobject.cpp
+++ b/qtdeclarative/src/qml/jsruntime/qv4stringobject.cpp
@@ -73,6 +73,11 @@
# include <windows.h>
#endif
+
+#if OS(SOLARIS)
+#include <alloca.h>
+#endif
+
using namespace QV4;
DEFINE_MANAGED_VTABLE(StringObject);
Qt做了很深的&#39; mkdir()
(例如mkdir -p
之类的内容,例如用于创建目录层次结构,例如~/.config/company/product
。如果现有目录位于不可写NFS内,Qt 5.2算法可能会在Solaris上中止太快挂载父 - 因为在这种情况下Solaris返回EACCESS
而不是EEXIST
。
--- a/qtbase/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/qtbase/src/corelib/io/qfilesystemengine_unix.cpp
@@ -579,6 +579,11 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
// on the QNet mountpoint returns successfully and reports S_IFDIR.
|| errno == ENOENT
#endif
+#if defined(Q_OS_SOLARIS)
+ // On Solaris 10, mkdir returns EACCESS on a directory which exists
+ // inside an NFS mount ...
+ || errno == EACCES
+#endif
) {
QT_STATBUF st;
if (QT_STAT(chunk.constData(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
Solaris也没有mkdtemp()
:
--- a/qtbase/src/corelib/io/qtemporarydir.cpp
+++ b/qtbase/src/corelib/io/qtemporarydir.cpp
@@ -52,7 +52,7 @@
#endif
#include <stdlib.h> // mkdtemp
-#if defined(Q_OS_QNX) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
+#if defined(Q_OS_QNX) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID) || defined(Q_OS_SOLARIS)
#include <private/qfilesystemengine_p.h>
#endif
@@ -96,7 +96,7 @@ static QString defaultTemplateName()
static char *q_mkdtemp(char *templateName)
{
-#if defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
+#if defined(Q_OS_QNX ) || defined(Q_OS_WIN) || defined(Q_OS_ANDROID) || defined(Q_OS_SOLARIS)
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const size_t length = strlen(templateName);
Solaris没有pthread_get_stacksize_np
(_np
后缀代表非便携式)。
Solaris还有另一个获取堆栈地址/大小值的函数。我的尝试:
--- a/qtdeclarative/src/qml/jsruntime/qv4engine.cpp
+++ b/qtdeclarative/src/qml/jsruntime/qv4engine.cpp
@@ -73,6 +73,11 @@
#include "qv4isel_moth_p.h"
#if USE(PTHREADS)
+
+#if OS(SOLARIS)
+#include <thread.h>
+#endif
+
# include <pthread.h>
#endif
@@ -103,6 +108,11 @@ quintptr getStackLimit()
} else
size = pthread_get_stacksize_np(thread_self);
stackLimit -= size;
+# elif OS(SOLARIS)
+ stack_t ss;
+ int r = thr_stksegment(&ss);
+ (void)r;
+ stackLimit = reinterpret_cast<quintptr>(ss.ss_sp);
# else
void* stackBottom = 0;
pthread_attr_t attr;
--- a/qtdeclarative/src/qml/jsruntime/qv4mm.cpp
+++ b/qtdeclarative/src/qml/jsruntime/qv4mm.cpp
@@ -67,6 +67,11 @@
#include <sys/storage.h> // __tls()
#endif
+#if OS(SOLARIS)
+#include <thread.h>
+#include <pthread.h>
+#endif
+
QT_BEGIN_NAMESPACE
using namespace QV4;
@@ -218,6 +223,11 @@ MemoryManager::MemoryManager()
# if OS(DARWIN)
void *st = pthread_get_stackaddr_np(pthread_self());
m_d->stackTop = static_cast<quintptr *>(st);
+# elif OS(SOLARIS)
+ stack_t ss;
+ int r = thr_stksegment(&ss);
+ (void)r;
+ m_d->stackTop = static_cast<quintptr *>(ss.ss_sp) + ss.ss_size/sizeof(quintptr);
# else
void* stackBottom = 0;
pthread_attr_t attr;
我建议仔细检查一下该代码,因为我的Qt代码不使用该Qt模块,因此,我没有对它进行太多测试。
Qt 5似乎在很大程度上依赖于XKB扩展。看来你不能在没有XKB支持的情况下构建Qt 5。它与xkbcommon捆绑在一起。
首先,确保找到正确的XKB数据库。否则键盘输入在你的Qt程序中根本不起作用!
Solaris没有默认值/usr/share/X11/xkb
。它改为:
/usr/X11/lib/X11/xkb
/usr/openwin/lib/X11/xkb
但是我没有幸运的话 - xkbcommon根本找不到任何组件。
我最终将/usr/share/X11/xkb
从cygwin发行版复制到自定义路径并将其配置为XKB数据库。
无论您选择哪种XKB,都必须对其进行配置:
--- a/qtbase/src/3rdparty/xkbcommon.pri
+++ b/qtbase/src/3rdparty/xkbcommon.pri
@@ -1,7 +1,12 @@
QMAKE_CFLAGS += -std=gnu99 -w
INCLUDEPATH += $$PWD/xkbcommon $$PWD/xkbcommon/src $$PWD/xkbcommon/src/xkbcomp
+solaris-g++-64 {
+DEFINES += DFLT_XKB_CONFIG_ROOT='\\"/MY/XKB/CHOICE\\"'
+} else {
DEFINES += DFLT_XKB_CONFIG_ROOT='\\"/usr/share/X11/xkb\\"'
+}
### RMLVO names can be overwritten with environmental variables (See libxkbcommon documentation)
DEFINES += DEFAULT_XKB_RULES='\\"evdev\\"'
对于测试,检查错误消息参数中的NULL值也是有意义的:
--- a/qtbase/src/3rdparty/xkbcommon/src/xkbcomp/xkbcomp.c
+++ b/qtbase/src/3rdparty/xkbcommon/src/xkbcomp/xkbcomp.c
@@ -68,8 +68,11 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap,
log_err(keymap->ctx,
"Couldn't look up rules '%s', model '%s', layout '%s', "
"variant '%s', options '%s'\n",
- rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant,
- rmlvo->options);
+ rmlvo->rules, rmlvo->model,
+ rmlvo->layout ? rmlvo->layout : "(NULL)",
+ rmlvo->variant ? rmlvo->variant : "(NULL)",
+ rmlvo->options ? rmlvo->options : "(NULL)"
+ );
return false;
}
您的XServer甚至可能不支持XKB扩展。同样,我不知道Qt 5是否可以在X下配置为禁用XKB支持。
您可以像这样检查您的X服务器:
xprop -root | grep xkb
或者调用随机的xkb程序,例如:
xkbvleds
此类通话不应导致如下错误:
Fatal Error: Server doesn't support a compatible XKB
如果您的XServer没有XKB,Qt程序可能会出现段错误。 Qt似乎没有真正检查XKB支持。当XKB不可用时,它似乎没有回退机制。
由于找不到模块,有些示例失败:
--- a/qtconnectivity/examples/bluetooth/scanner/scanner.pro
+++ b/qtconnectivity/examples/bluetooth/scanner/scanner.pro
@@ -1,4 +1,4 @@
-QT = core bluetooth quick
+QT = core bluetooth # quick
SOURCES += qmlscanner.cpp
TARGET = qml_scanner
diff --git a/qtconnectivity/examples/nfc/poster/poster.pro b/qtconnectivity/examples/nfc/poster/poster.pro
index d108b2a..d0d0659 100644
--- a/qtconnectivity/examples/nfc/poster/poster.pro
+++ b/qtconnectivity/examples/nfc/poster/poster.pro
@@ -1,4 +1,4 @@
-QT += qml quick network nfc widgets
+QT += qml network nfc widgets # quick
SOURCES += \
qmlposter.cpp
它们也是没有构建的。
A gmake install
令人惊讶地触发了几个尚未编译的模块的编译。因此,并行执行它是有意义的:
$ gmake -j16 install
(假设您的系统有足够数量的核心)
捆绑的QtHelp模块不是使用主编译/安装步骤构建/安装的。
解决这个问题:
cd qttools
PATH=$MY_PREFIX/bin:$PATH qmake
gmake
gmake install
truss -u :
显示libm / QtWidget内的函数调用 - 可能系统太慢了和/或某些代码 - Solaris上没有优化路径/与ssh上的X-forwarding结合使用Qt Warning: Could not find a location of the system's Compose files. Consider setting the QTCOMPOSE environment variable.
- 不知道这是什么功能通过这些调整&#39;正常&#39; Qt程序(没有QtSvg)编译 并在Solaris 10下正常运行。