mcallegari / qlcplus

Q Light Controller Plus (QLC+) is a free and cross-platform software to control DMX or analog lighting systems like moving heads, dimmers, scanners etc. This project is a fork of the great QLC project written by Heikki Junnila that aims to continue the QLC development and to introduce new features.
Apache License 2.0
918 stars 349 forks source link

Fix build/linker issues with recent GCC releases and static libraries #1552

Closed cmuellner closed 2 months ago

cmuellner commented 2 months ago

Building qlcplus (upstream/master) with GCC 13.2.1 (Fedora 39) triggers build errors when using the following commands:

mkdir build
cd build
cmake ..
make

The first error is:

[...]
[ 10%] Linking CXX shared library libqlcplusengine.so
/usr/bin/ld: ../audio/src/libqlcplusaudio.a(audio.cpp.o): relocation R_X86_64_32 against symbol `_ZTV5Audio' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

The second error is:

[...]
[ 46%] Linking CXX shared library libqlcplusengine.so
/usr/bin/ld: ../../hotplugmonitor/src/libhotplugmonitor.a(hotplugmonitor.cpp.o): relocation R_X86_64_32 against symbol `_ZTV14HotPlugMonitor' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

Both errors are caused by linking a static library without position-independent code into a shared object.

This patch addresses the build errors by enabling position-independent code generation for the two static libraries.

coveralls commented 2 months ago

Coverage Status

coverage: 32.081%. remained the same when pulling e720c6eb9706071a3e5fbdd7cde61adf1e27fb3b on cmuellner:fedora-relocation into 58d4ee220b21660c1fbcded7dd9e8b8f64fdfaa7 on mcallegari:master.

mcallegari commented 2 months ago

@cmuellner thanks for this. Before merging, can you please confirm if specifying the Qt location as per wiki instructions it works correctly? https://github.com/mcallegari/qlcplus/wiki/Linux-build-(Qt5-&-cmake)#compile

Thanks

cmuellner commented 2 months ago

The PR was initially tested on Fedora 39 and linking qlcplus+changes against QT6 using the following commands:

cd build
mkdir build
cmake ..
make

I've now created an Ubuntu 23.10 VM and installed all build dependencies for a QT5 build. Then I've built qlcplus+changes using the following commands from the wiki:

cd build
mkdir build
cmake -DCMAKE_PREFIX_PATH="/usr/lib/x86_64-linux-gnu/cmake/Qt5" ..
make

Starting qlcplus worked fine.

I don't have a QT account, so I haven't tested building against the official (proprietary) Qt release.

mcallegari commented 2 months ago

Thanks :+1: