I'm trying to build the static libraries of Eclipse Paho MQTT C on a Raspberry Pi 3 B+. As a prerequisite it is necessary to have the static version of the OpenSSL library on the system.
First, I attempted to get it using the following commands:
git clone git://git.openssl.org/openssl.git
cd openssl
git checkout OpenSSL_1_1_1a
./config -static
sudo make install
This does produce a libssl.a
File in /usr/local/lib
. However, when I then try to build the static libraries of Paho using the following commands, it fails with the error below:
git clone https://github.com/eclipse/paho.mqtt.c.git
mkdir /tmp/build.paho
cd /tmp/build.paho
cmake -GNinja -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_STATIC=TRUE ~/paho.mqtt.c
ninja
/usr/bin/ld: /usr/local/lib/libssl.a(methods.o): relocation R_ARM_MOVW_ABS_NC against ‘a local symbol’ can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libssl.a: error adding symbols: Bad value
The suggested solution to this problem in several Stackoverflow questions seems to be to build the static OpenSSL library with the shared
flag: ./config shared -static
But even then, building of the static Paho libraries fails with the exact same error.
I should add that I did not have any troubles with this procedure on other hardware architectures. Could this problem be related to the Raspberry Pi in any way? How do I solve it?