Error when including library in vala project

I am using Gnome builder for a .vala project. In this project I want to use libserialport of which I have the library and -devel packages installed. At first I was having issues with the vala part of the library, which turned out to be the .vapi file missing which was easily solved. However now I’m having trouble with the C library part of it and am getting the following error if I include it as: meson.get_compiler('c').find_library('libserialport')

C shared or static library ‘libserialport’ not found

It does show up in pkgconfig pkg-config --list-package-names | grep libserialport and I can find the library in /usr/lib64

Contents of /urs/lib64/pkgconfig/libserialport.pc:


Name: libserialport
Description: Cross-platform serial port access library.
Version: 0.1.1
Libs: -L${libdir} -lserialport
Cflags: -I${includedir}

You need find_library('serialport')

See Vala

but if it has a .pc file, you could and probably should just do dependency('libserialport') anyway?

I’d indeed expect dependecy('libserialport') to work, but it doesn’t. I think it might be because it is in /usr/lib64 not /usr/lib(running Fedora). However I don’t know how to make it use lib64.

Btw also tried find_library('serialport') but that doesn’t work either. Or any variation of it with dependecy.

Since you are using Builder, it is possible that you are building a flatpak. If this is the case, it won’t find libraries installed in your host system. You need to add (instructions for building) the libraries you need to the flatpak manifest.

That is probably it (I am using flatpak build). Is there a simple way to add it to the manifest (from e.g. pkconfig)? Did a quick search, but haven’t found it. If you don’t, no problem, I’ll at least have something to do this weekend. :stuck_out_tongue:

You don’t add it from the pkg-config. You add instructions on how to build it from sources (so you don’t need to install it on your system). You need to do something like what is described here.

Alright. So here is my genius solution (for anyone reading this at a later time): “don’t bother with flatpak”.
I’m not going to build all dependencies locally if I have them right here already. Seems kind of a flaw of flatpak tbh. If you have any closed source dependency you can’t make a flatpak.

Sure, your choice.

No, that is incorrect. Otherwise there wouldn’t be hundreds of proprietary apps on flathub.

In the mean time I have it building in flatpak since I only have one dependency.

No, that is incorrect. Otherwise there wouldn’t be hundreds of proprietary apps on flathub.

But how would you then include closed source dependency? I can’t find any documentation how to link a local, prebuild, library file.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.