Installing custom libraries into SDK targets

I am trying to use a library in my project and I managed to compile it using cmake and then running make. Now I need to install it in the current target so that I can use the library and the development files related to it.

I did the following but it fails:

[SailfishOS-] build $ make install

This fails because it copies the files to /usr/local/bin but apparently with the current version of the SDK this is mounted as a read-only filesystem. I think this was possible before. What is the correct way to do this?


To be able post your application to Harbour, you have to distribute third-party libraries together with your application (in one rpm package) in allowed path. You cannot keep it in /usr/local/lib or similar paths (multiple applications from harbour may conflict). What I may recommend you is to move your library to /usr/share/harbour-<app-name>/lib. And then setup rpath of your binary to that path to be able load that library.

If you are using cmake for your application, add ExternalProject_Add to your project, make it work with third-party library, install libraries to correct place and add cmake argument -DCMAKE_INSTALL_RPATH=%{_datadir}/%{name}/lib/: to your *.spec file that describes how to build rpm package…

Or, when license of your app and library allows that, build that library as a static library (again, using ExternalProject_Add) and then link it with your application… You don’t have to solve proper installation and rpath…

Hope that it helps :slight_smile:


Additional information for those who needs to deal with custom(ized) build time dependencies as separate packages.

Custom build time dependencies can be conveniently installed with the help of the search-output-dir configuration option of sfdk (Qt Creator uses sfdk for building). This option is best combined with output-prefix <dir> option, which also implies it:

mkdir -p ~/tmp/RPMS
sfdk config --global --push output-prefix "$HOME/tmp/RPMS"

With this configuration, sfdk will store all RPMs in subdirectories of ~/tmp/RPMS and it will also search those directories for build time dependencies. See sfdk --help-building for more information.

Note that Qt Creator builds the RPMs only during the deployment step, not during the build step. This means that the library RPMs will not be created until the library is deployed. You may configure your library project to use the “Build RPM Packages for Manual Deployment” deployment method to avoid the need to actually deploy the library when you only need it as a build time dependency.

Turns out that RPM macro %cmake disables RPATH handling. So, if you wish to use RPATH in your project with cmake, use cmake in the SPEC and add -DCMAKE_INSTALL_RPATH=%{_datadir}/%{name}/lib/: as suggested by @Karry above.

As for ExternalProject_Add, it all depends on your application and approach. I have not used it myself and just used INSTALL_RPATH.

Is it possible to mix qmake and cmake steps? I have a library with functional cmake and would like to use qmake for the main project. So, a build step that specifies cmake before the app build?

Please create a new topic for your question. It definitely deserves it.

Ok, Will do! The practical case I was working on is small enough to take the cmake part and turn it into qmake (single header file). But that’s probably an exception.

Update: SDK multiple build steps, qmake and cmake