Is that possible to build static Qt library with w

2019-02-09 03:54发布

I tried to build static Qt library with the following command:

./configure --prefix=/usr/local/qt --static --accessibility --multimedia --audio-backend --svg --webkit --javascript-jit --script --scripttools --declarative --dbus --debug

But I got a message said:

WARNING: Using static linking will disable the WebKit module.

Is that possible to build static Qt library with all modules enabled? and how?

Thanks

5条回答
SAY GOODBYE
2楼-- · 2019-02-09 04:38

Might be because parts of it are LGPL. So, it's probably possible, but the LGPL would mean that you have to provide source or compiled object code so that an end-user could relink against their own version.

If you are not deploying the result to anyone, then you could probably do it and comply.

You'll have to edit the build to actually do it though, since it looks like they comply with LGPL by default.

查看更多
姐就是有狂的资本
3楼-- · 2019-02-09 04:44

For Qt 4.8.3 I had to patch the .pro files to make a single QtWebKit instead of separate WebKit and JavaScriptCore libraries. The linker gets confused because there are inter-dependencies between the two libraries.

Not sure if a similar approach will work for your Qt 4.7.1.

I'm not going to mention the licensing issues.

diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf
index d60533e..6a7ffa7 100644
--- a/mkspecs/common/linux.conf
+++ b/mkspecs/common/linux.conf
@@ -7,8 +7,8 @@ QMAKE_CXXFLAGS_THREAD   += $$QMAKE_CFLAGS_THREAD

 QMAKE_INCDIR          =
 QMAKE_LIBDIR          =
-QMAKE_INCDIR_X11      = /usr/X11R6/include
-QMAKE_LIBDIR_X11      = /usr/X11R6/lib
+QMAKE_INCDIR_X11      = /usr/include/X11
+QMAKE_LIBDIR_X11      = /usr/lib/X11
 QMAKE_INCDIR_QT       = $$[QT_INSTALL_HEADERS]
 QMAKE_LIBDIR_QT       = $$[QT_INSTALL_LIBS]
 QMAKE_INCDIR_OPENGL   = /usr/X11R6/include
diff --git a/mkspecs/linux-g++-64/qmake.conf b/mkspecs/linux-g++-64/qmake.conf
index 222f6b7..3780295 100644
--- a/mkspecs/linux-g++-64/qmake.conf
+++ b/mkspecs/linux-g++-64/qmake.conf
@@ -20,7 +20,7 @@ include(../common/gcc-base-unix.conf)
 include(../common/g++-unix.conf)


-QMAKE_LIBDIR_X11      = /usr/X11R6/lib64
-QMAKE_LIBDIR_OPENGL   = /usr/X11R6/lib64
+QMAKE_LIBDIR_X11      = /usr/lib/X11
+QMAKE_LIBDIR_OPENGL   = /usr/lib/X11

 load(qt_config)
diff --git a/src/3rdparty/webkit/Source/WebKit.pro b/src/3rdparty/webkit/Source/WebKit.pro
index 9be0f4a..c1e575d 100644
--- a/src/3rdparty/webkit/Source/WebKit.pro
+++ b/src/3rdparty/webkit/Source/WebKit.pro
@@ -3,14 +3,9 @@ CONFIG += ordered

 include(WebKit.pri)

-!v8 {
-    exists($$PWD/JavaScriptCore/JavaScriptCore.pro): SUBDIRS += JavaScriptCore/JavaScriptCore.pro
-    exists($$PWD/JavaScriptCore/jsc.pro): SUBDIRS += JavaScriptCore/jsc.pro
-}

 webkit2:exists($$PWD/WebKit2/WebKit2.pro): SUBDIRS += WebKit2/WebKit2.pro

-SUBDIRS += WebCore
 SUBDIRS += WebKit/qt/QtWebKit.pro

 webkit2 {
diff --git a/src/3rdparty/webkit/Source/WebKit/qt/QtWebKit.pro b/src/3rdparty/webkit/Source/WebKit/qt/QtWebKit.pro
index 847f6f4..e2daf24 100644
--- a/src/3rdparty/webkit/Source/WebKit/qt/QtWebKit.pro
+++ b/src/3rdparty/webkit/Source/WebKit/qt/QtWebKit.pro
@@ -2,7 +2,6 @@
 CONFIG += building-libs
 CONFIG += depend_includepath

-TARGET = QtWebKit
 TEMPLATE = lib
查看更多
爷、活的狠高调
4楼-- · 2019-02-09 04:44

Almost impossible. Webkit uses stand along makefiles other than the makefiles generated by configure tool. You can check src\3rdparty\webkit\source yourself.

If you tried to compile Qt static with webkit, you'll meet a error says cannot find -lwebcore. In fact, the webcore.a is generated at src\3rdparty\webkit\source\webcore\release, so does -ljscore. But if you copy them to /lib yourslef, link error always popup.

I've tried to edit makefiles of webcore and jscore adding -static, but it didn't work at all.

Sadly, that's all what I got now.

查看更多
虎瘦雄心在
5楼-- · 2019-02-09 04:47

Nothing to do with LGPL issues, since your app could be open source and licensed in a way that would be compatible with the LGPL.

Apparently statically linked WebKit is unsupported for technical reasons. (Some compilers seem to not be happy with it). The build script has been updated in commit 4221d629e2cf37ee8c5ba7cb595b05ab8c82f113 to explicitly prevent it:

Removed support for static linking of QtWebKit. Static linking of WebKit is not going to be supported anymore in Qt 4.7, so this commit makes sure it's mentioned in the documentation and that configure disables WebKit if static linking of Qt is requested.

https://www.qt.gitorious.org/qt/qt/commit/4221d629e2cf37ee8c5ba7cb595b05ab8c82f113

It may or may not work with your compiler, but I suspect the Qt team didn't want to go into the trouble of maintaining that for all the officially supported architectures.

查看更多
Deceive 欺骗
6楼-- · 2019-02-09 04:51

Well, Lou Franco is right, using the LGPL and compiling statically does not really comply the LGPL. What most Qt "users" or developers do is, to compile dynamically, prividing their "own compiled" libraries in the application directory. This is okay with the LGPL as long as you did not change any code in Qt / QtWebKit / WebKit itself and did not provide the changes to upstream.

查看更多
登录 后发表回答