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:

1 Like

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.