Thanks Guilherme,
I will definitely take a look at your build system. In the meantime I have the library working with the pre-compiled libs. To bundle them with my application I copy them to my executables folder and have a post build script like so:
install_name_tool -change libpaho-mqtt3a.so.1 @executable_path/libpaho-mqtt3a.so.1 "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
Will see how I go on Windows. Cheers, Rene.
Date: Tue, 3 May 2016 12:36:35 -0500 From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@xxxxxxxxx> To: General development discussions for paho project <paho-dev@xxxxxxxxxxx> Subject: Re: [paho-dev] Compiling static libs Message-ID: <CAF=5bWdcircbUGAV7TTOjEgfPbwNNoyS0apM+uBPu77ktQbBKQ@xxxxxxxxxxxxxx> Content-Type: text/plain; charset=UTF-8
Hi Rene Christen,
2016-05-03 2:14 GMT-05:00 Rene Christen <contact@xxxxxxxxxxxxxxxx>:
Hi there,
This lib looks great. I need to use it as a static lib in a 64 bit windows and 64 bit OSX project. Is this possible?
I've been cooking an Autotools build system for Paho MQTT C. It can help you build a static version of those libraries for OSX:
$ git clone https://github.com/guilhermeferreira/paho.mqtt.c.git $ cd paho.mqtt.c $ git checkout -t origin/autotools $ ./bootstrap $ ./configure --enable-shared=no --enable-static=yes --enable-samples=yes --with-ssl=no --enable-peak-warnings=no $ make
Regarding the Windows build, I guess you can use CMake build system. However, I'm not sure if the current project's scripts build a static version.
I have not been able to compile it yet (trying OSX first). I checked out the cpp and c git hub repos. I set the path to the c header files with export PAHO_C_HEADERS=xxx. I was then getting errors that it couldn?t find malloc() so added these lines to the top of client_persistence.cpp:
#include <stdlib.h> #include <string.h>
now when I run make I get:
ld: unknown option: -soname
Any advice? I?m not that savvy with makefiles.
Soname is a softlink with name libname.so.major. It is used to bind applications to a specific library API. For example, libmqtt.so.3.2 and libpaho.so.3.1 have the same interface (major version = 3), but are incompatible with libmqtt.so.2.
I guess OSX linker has something similar to the soname option. I saw some people using -Wl,-install_name instead of -Wl,-soname, but I'm not sure about this. Maybe this article can answer some questions [https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/CreatingDynamicLibraries.html#//apple_ref/doc/uid/TP40002073-SW1]
Kind regards,
-- Guilherme Maciel Ferreira Mobile Brazil: +55 48 9917 3969 Site: http://guilhermemacielferreira.com/ Skype: guilherme.maciel.ferreira |