Best Practice: build a small library for package local linking

I’m struggling to set up the qmake builds which include a small library. I had thought to use the:
template = subdir approach. But I’m not sure.

The library files themselves depend on SDL2 and SDL2_mixer. Obviously they should deploy to the local lib directory of the app itself.

What’s the best way to structure this in the app SDK. Use a toplevel subdir template and then the and files in subdirs?

EDIT: the library I’m trying to build/include in the project is: synth/lib at master · hsaturn/synth · GitHub (from my clone thereof).

I tried using include mechanisms but this does not work (for reasons obvious to some :slight_smile:

Is it just a question of setting up a buld step that builds the lib first? Switching between the pro and pri files is not getting me there.

I’m pretty sure it is not “best practice”, but you can have a look at how it’s done in kontroller: GitHub - Julien-Blanc-tgcm/kontroller (yes, it follows the subdir approach), it compiles qjsonrpc as part of the build process. It’s been real pita to make it work iirc (but I’m really not a qmake guru). And if the library is using anything else than a .pro file, you’re dead.

In the latter case i I would migrate to cmake.

Thanks! That’s what I was looking for. I think it’d be great to mix and match cmake and qmake but obviously a nightmarish scenario :wink:

EDIT: I think from a QT perspective, it is ‘Textbook’ aka ‘Best Practice’ ! I just needed an example with sailfish context but you have multiple targets.

EDIT2: The one significant difference that I see on closer inspection is that you are including via git a QT project. So, if I understand correctly the qjsonrpc library is pulled from it’s repo and since it has a compatible build will work with your dirs based template. That brings me back to how to include a foreign build.

For the time being, since it’s small and no one but the author (and now me) are working on it, I can just twist it into a qmake build, but for the future, I should work out how to add another make step.

Ok, just looking through the .git files I don’t see how the qjsonrpc library is being pulled from it’s parent? But I’m a ‘primitive’ git user. I tried:

git submodule update --init --recursive
which get’s

Submodule 'qjsonrpc' ( registered for path 'qjsonrpc'
Cloning into '/home/mwa/src/sailfish/kontroller/qjsonrpc'...
remote: Not Found

Yes, obviously i messed up when i set the url. Since this repo never changed, i did not notice it.

You can simply git clone in the qjsonrpc directory, that will do it (will fix that, but i don’t have the time right now).

Thanks. I’ll try this now! I’m still not succeeding in get the lib installed but everything compiles :wink:

I’ve got a build for included static build that I’m going to use as a how-to. It’s an SDL audio synth. But it’s going to take some time before i can turn it into a proper how-to:

the name may move …