[PATCH] Don't require Qt GUI module

52 views
Skip to first unread message

Arnout Vandecappelle (Essensium/Mind)

unread,
Nov 13, 2012, 6:36:37 PM11/13/12
to qextser...@googlegroups.com, Arnout Vandecappelle (Essensium/Mind)
From: "Arnout Vandecappelle (Essensium/Mind)" <arn...@mind.be>

The GUI module is not strictly needed for qextserialport. Only on Windows
platforms it is needed for the QextSerialRegistrationWidget.

This allows qextserialport to run on (embedded) platforms where Qt doesn't
include the GUI module.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arn...@mind.be>
---
qextserialport.pro | 2 ++
1 file changed, 2 insertions(+)

diff --git a/qextserialport.pro b/qextserialport.pro
index 78cf855..8fb52d0 100644
--- a/qextserialport.pro
+++ b/qextserialport.pro
@@ -41,6 +41,8 @@ macx:qesp_mac_framework {

win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all

+!win32*:!wince*:QT -= gui
+
#generate proper library name
greaterThan(QT_MAJOR_VERSION, 4) {
QESP_LIB_BASENAME = QtExtSerialPort
--
1.7.10.4

Lisandro Damián Nicanor Pérez Meyer

unread,
Nov 14, 2012, 7:17:14 AM11/14/12
to qextser...@googlegroups.com, Arnout Vandecappelle (Essensium/Mind)
On Tue 13 Nov 2012 20:36:37 Arnout Vandecappelle (Essensium/Mind) escribió:
> From: "Arnout Vandecappelle (Essensium/Mind)" <arn...@mind.be>
>
> The GUI module is not strictly needed for qextserialport. Only on Windows
> platforms it is needed for the QextSerialRegistrationWidget.
>
> This allows qextserialport to run on (embedded) platforms where Qt doesn't
> include the GUI module.
>
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arn...@mind.be>

Hi Arnout! I packaged latest repo HEAD and didn't need to use the GUI stuff
during linking.

I may be missing something too.

Kinds regards, Lisandro.

--
Evite los parámetros estáticos. Si son inevitables, haga que el emisor
y el receptor negocien un valor.
Andrew S. Tanenbaum, de su libro "Computer Networks"

Lisandro Damián Nicanor Pérez Meyer
http://perezmeyer.com.ar/
http://perezmeyer.blogspot.com/
signature.asc

Arnout Vandecappelle

unread,
Nov 14, 2012, 7:53:33 AM11/14/12
to qextser...@googlegroups.com, Lisandro Damián Nicanor Pérez Meyer
On 14/11/12 13:17, Lisandro Dami�n Nicanor P�rez Meyer wrote:
> On Tue 13 Nov 2012 20:36:37 Arnout Vandecappelle (Essensium/Mind) escribi�:
>> From: "Arnout Vandecappelle (Essensium/Mind)"<arn...@mind.be>
>>
>> The GUI module is not strictly needed for qextserialport. Only on Windows
>> platforms it is needed for the QextSerialRegistrationWidget.
>>
>> This allows qextserialport to run on (embedded) platforms where Qt doesn't
>> include the GUI module.
>>
>> Signed-off-by: Arnout Vandecappelle (Essensium/Mind)<arn...@mind.be>
>
> Hi Arnout! I packaged latest repo HEAD and didn't need to use the GUI stuff
> during linking.
>
> I may be missing something too.

Do you mean that you were able to build qextserialport against a Qt installation
that doesn't have QtGui? Because that is the problem I'm facing: the dynamic
library is linked with -lQtGui, but there is no QtGui library.

It's true that after the link, there will not be a dependency on QtGui.so
because qextserialport doesn't use any of QtGui's symbols.

Regards,
Arnout

--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286540
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

Lisandro Damián Nicanor Pérez Meyer

unread,
Nov 15, 2012, 9:07:23 PM11/15/12
to qextser...@googlegroups.com
Bah, I sent this privately to Arnaud instead of to the list.

Arnaud, can you please resend your replies to the list?

Kinds regards, Lisandro.

On Wed 14 Nov 2012 09:53:33 usted escribió:
[snip]
> Do you mean that you were able to build qextserialport against a Qt
> installation that doesn't have QtGui? Because that is the problem I'm
> facing: the dynamic library is linked with -lQtGui, but there is no QtGui
> library.

Correct.

> It's true that after the link, there will not be a dependency on QtGui.so
> because qextserialport doesn't use any of QtGui's symbols.

In platforms != Windows AFAIU.

If I correctly understand, with the last fix to the build system, QtGui is
only linked on Windows, as it should.

You can check the latest commit on the repo or get the source tarball I used
to create the package from Debian:

<http://ftp.de.debian.org/debian/pool/main/q/qextserialport/qextserialport_1.2.0~beta2+git12-
ge279110.orig.tar.bz2>


Kinds regards, Lisandro.

--
The generation of random numbers is too important to be left to chance.
http://www.devtopics.com/best-programming-jokes/
signature.asc

Arnout Vandecappelle

unread,
Nov 19, 2012, 1:26:01 AM11/19/12
to qextser...@googlegroups.com, Lisandro Damián Nicanor Pérez Meyer
On 16/11/12 03:07, Lisandro Dami�n Nicanor P�rez Meyer wrote:
> Bah, I sent this privately to Arnaud instead of to the list.
>
> Arnaud, can you please resend your replies to the list?
>
> Kinds regards, Lisandro.
>
> On Wed 14 Nov 2012 09:53:33 usted escribi�:
> [snip]
>> Do you mean that you were able to build qextserialport against a Qt
>> installation that doesn't have QtGui? Because that is the problem I'm
>> facing: the dynamic library is linked with -lQtGui, but there is no QtGui
>> library.
>
> Correct.
>
>> It's true that after the link, there will not be a dependency on QtGui.so
>> because qextserialport doesn't use any of QtGui's symbols.
>
> In platforms != Windows AFAIU.
>
> If I correctly understand, with the last fix to the build system, QtGui is
> only linked on Windows, as it should.
>
> You can check the latest commit on the repo or get the source tarball I used
> to create the package from Debian:
>
> <http://ftp.de.debian.org/debian/pool/main/q/qextserialport/qextserialport_1.2.0~beta2+git12-
> ge279110.orig.tar.bz2>


I checked again, and here are the issues:

- AFAICS, on all platforms, the default mkspecs does 'QT += gui' (and usually
also network), even if there is no QtGui library. Also, according to the qmake
documentation: "If you want to build a project without the QtGui module, you
need to exclude the gui value with the "-=" operator."

- As a check, I built current git against the (Debian) Qt install on my laptop:
g++ -m64 -Wl,-O1 -shared -Wl,-soname,libqextserialport.so.1 -o libqextserialport.so.1.2.0 qextserialport.o
qextserialenumerator.o qextserialport_unix.o qextserialenumerator_linux.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore
-lpthread

$ readelf -d libqextserialport.so

Dynamic section at offset 0xf250 contains 32 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libQtGui.so.4]
0x0000000000000001 (NEEDED) Shared library: [libQtCore.so.4]
...


So I think removing gui from qmake's QT variable is a good idea in general.

And some platforms add network and/or opengl to QT as well, so they should
also be removed.

Lisandro Damián Nicanor Pérez Meyer

unread,
Nov 19, 2012, 7:35:48 AM11/19/12
to qextser...@googlegroups.com
On Mon 19 Nov 2012 03:26:01 Arnout Vandecappelle escribió:
[snip]

Once again ¿with what version of the code did you try?

The following comes from the latest HEAD:

lisandro@luna:/usr/lib/x86_64-linux-gnu$ readelf -d libqextserialport.so

Dynamic section at offset 0xed50 contains 30 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libQtCore.so.4]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname:
[libqextserialport.so.1]

So, no use of libQtGui.

--
1: Una computadora sirve:
* Para tratar de dominar el mundo, un caso conocido de esto fue el de
Skinet
Damian Nadales
http://mx.grulic.org.ar/lurker/message/20080307.141449.a70fb2fc.es.html
signature.asc

Arnout Vandecappelle

unread,
Nov 19, 2012, 7:48:43 AM11/19/12
to qextser...@googlegroups.com, Lisandro Damián Nicanor Pérez Meyer


On 19/11/12 13:35, Lisandro Dami�n Nicanor P�rez Meyer wrote:
[snip]
My qextserialport version:
6c47244 Fix Issue 152: QextReadBuffer::reserve does not reserve enough

(it's what I think is current git, unless I'm looking at the wrong repo)

bash 51985$ qmake --version
QMake version 2.01a
Using Qt version 4.8.2 in /usr/lib/x86_64-linux-gnu

spec file used:
/usr/share/qt4/mkspecs/default -> linux-g++-64/

(that spec includes core and gui)

qmake; make results in:

...
g++ -m64 -Wl,-O1 -shared -Wl,-soname,libqextserialport.so.1 -o libqextserialport.so.1.2.0 qextserialport.o
qextserialenumerator.o qextserialport_unix.o qextserialenumerator_linux.o -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore
-lpthread


Regards,
Arnout
--
Arnout Vandecappelle arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . +32-16-286540 . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 31BB CF53 8660 6F88 345D 54CC A836 5879 20D7 CF43


Lisandro Damián Nicanor Pérez Meyer

unread,
Nov 19, 2012, 4:51:42 PM11/19/12
to qextser...@googlegroups.com, Arnout Vandecappelle
On Mon 19 Nov 2012 09:48:43 Arnout Vandecappelle escribió:
[snip]
> My qextserialport version:
> 6c47244 Fix Issue 152: QextReadBuffer::reserve does not reserve enough
>
> (it's what I think is current git, unless I'm looking at the wrong repo)
>
> bash 51985$ qmake --version
> QMake version 2.01a
> Using Qt version 4.8.2 in /usr/lib/x86_64-linux-gnu
>
> spec file used:
> /usr/share/qt4/mkspecs/default -> linux-g++-64/
>
> (that spec includes core and gui)
>
> qmake; make results in:
>
> ...
> g++ -m64 -Wl,-O1 -shared -Wl,-soname,libqextserialport.so.1 -o
> libqextserialport.so.1.2.0 qextserialport.o qextserialenumerator.o
> qextserialport_unix.o qextserialenumerator_linux.o
> -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread

Indeed, it's me who's telling the linker not to add the QtGui dependency, I'm
adding -Wl,-as-needed in LDFLAGS.

I think your patch is right :-) (without testing it, I don't have windows).

Kinds regards, Lisandro.

--
http://www.tiraecol.net/modules/comic/comic.php?content_id=162
signature.asc
Reply all
Reply to author
Forward
0 new messages