# pkgconf --exists "gtkmm-3.0" returns nothing



## marcelbonnet (Mar 1, 2018)

Hi.

I'm wondering why pkgconf do not confirm the existence of gtkmm-3.0 :


```
[@machine root]$ pkgconf --exists "gtkmm-3.0"
[@machine root]$ pkg iinfo gtkmm
gtkmm24-2.24.4_3
gtkmm30-3.22.0
```

Thanks, in advance.


----------



## tobik@ (Mar 1, 2018)

It's a silent command and it confirms the existence of a module by exiting with status 0. If it wouldn't exist it would exit with something non-zero. Looks like the documentation in pkgconf(1) is wrong here though and has flipped that around (EDIT: filed a bug https://github.com/pkgconf/pkgconf/pull/173).

Try `pkgconf --exists gtkmm-3.0 && echo "gtkmm-3.0 exists"`


----------



## marcelbonnet (Mar 1, 2018)

tobik@ said:


> It's a silent command and it confirms the existence of a module by exiting with status 0. If it wouldn't exist it would exit with something non-zero. Looks like the documentation in pkgconf(1) is wrong here though and has flipped that around (EDIT: filed a bug https://github.com/pkgconf/pkgconf/pull/173).
> 
> Try `pkgconf --exists gtkmm-3.0 && echo "gtkmm-3.0 exists"`



Thanks, but pkg exit status is 1 (echo above is also empty). Why, if gtkmm seems to be installed? Where is the problem?


----------



## tobik@ (Mar 1, 2018)

Hmm,  this works fine here. Does /usr/local/libdata/pkgconfig/gtkmm-3.0.pc exist on your system? If yes, what's in it? Do you overwrite or set any environment variables like PKG_CONFIG_PATH or similar (pkgconf(1) has a complete list of those)?


----------



## marcelbonnet (Mar 1, 2018)

tobik@ said:


> Hmm,  this works fine here. Does /usr/local/libdata/pkgconfig/gtkmm-3.0.pc exist on your system? If yes, what's in it? Do you overwrite or set any environment variables like PKG_CONFIG_PATH or similar (pkgconf(1) has a complete list of those)?



Thanks. The pc file is attached .

Works for you? Oh, no , these are the worst problems to solve .   I need a  first.

I don't remember to set any env var in the past.

`env | grep PKG` returns nothing.

The man page says:

PKG_CONFIG_PATH
             List of secondary directories where ‘.pc’ files are looked up.

So I tried this:


```
[@machine tmp]$  export PKG_CONFIG_PATH=/usr/local/libdata/pkgconfig/
[@machine tmp]$  pkgconf --exists gtkmm-3.0 && echo "gtkmm-3.0 exists"
[@machine tmp]$  pkgconf --exists gtkmm-3.0
[@machine tmp]$  echo $?
1
```

Now I'll read some online docs and try to figure out the default values used when the environment variables are not set. Meanwhile, I'll appreciate suggestions!


----------



## marcelbonnet (Mar 1, 2018)

Weird...


```
[@machine ~]$  echo $PKG_CONFIG_PATH

[@machine ~]$  pkgconf --list-all | grep gtkmm
gtkmm-2.4                      gtkmm - C++ binding for the GTK+ toolkit
gtkmm-3.0                      gtkmm - C++ binding for the GTK+ toolkit
```


----------



## marcelbonnet (Mar 1, 2018)

Unfortunately, the program does not rely on GTK 2.4 , see:


```
[@machine tmp]$  pkgconf --exists gtkmm-2.4 && echo "gtkmm-2.4 exists!"                                                                                                                         
gtkmm-2.4 exists!
```

I really don't understand what is happening here.


----------



## ShelLuser (Mar 1, 2018)

I can definitely confirm some weird behavior, using FreeBSD 11.1 and this also doesn't quite work for me, not even with existing packages. Still, I can't help wonder if pkgconf was actually build for this.

It might be better to rely on PKG itself, that's what I always do: `pkg info -e javamail`.

(edit)

```
unicron:/home/peter $ pkgconf --exists "javamail" && echo "yay!"
unicron:/home/peter $ pkg info -e javamail && echo "yay!"
yay!
```
Peculiar indeed, not to mention quite unreliable


----------



## ShelLuser (Mar 1, 2018)

Sorry for a double post but I think I discovered a possible cause, truss to the rescue:


```
lstat("/usr/libdata/pkgconfig",{ mode=drwxr-xr-x ,inode=12912,size=7,blksize=409
6 }) = 0 (0x0)
open("/usr/local/libdata/pkgconfig/javamail-uninstalled.pc",O_RDONLY,0666) ERR#2 'No such file or directory'
open("/usr/local/libdata/pkgconfig/javamail.pc",O_RDONLY,0666) ERR#2 'No such file or directory'
open("/usr/libdata/pkgconfig/javamail-uninstalled.pc",O_RDONLY,0666) ERR#2 'No such file or directory'
open("/usr/libdata/pkgconfig/javamail.pc",O_RDONLY,0666) ERR#2 'No such file or directory'
open("/usr/local/libdata/pkgconfig",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,00) = 3 (0x3)
```
So further examining /usr/libdata/pkgconfig showed me some other files being present (very few) and guess what?


```
unicron:/home/peter $ ls /usr/libdata/pkgconfig/
liblzma.pc      libusb-0.1.pc   libusb-1.0.pc   libusb-2.0.pc   zlib.pc
unicron:/home/peter $ pkgconf --exists zlib && echo yay!
yay!
unicron:/home/peter $ pkgconf --exists javamail && echo yay!
```
From what I can tell this software doesn't even come close to checking the actual package database but uses some arcane locations of its own. I mean, hier(7) doesn't mention pkgconfig which makes me suspect that this software started to mess with that location on its own. My file timestamps seems to collaborate with this idea:


```
drwxr-xr-x  2 root  wheel   2 Jul 21  2017 gcc
drwxr-xr-x  2 root  wheel  28 Dec 31 03:43 ldscripts
drwxr-xr-x  2 root  wheel   4 Dec 31 03:47 lint
drwxr-xr-x  2 root  wheel   8 Mar  1 21:54 pkgconfig
```
I can tolerate gcc being there because of hier(7) mentioning it, but pkgconfig?

Bottom line: I wouldn't rely on this software, use pkg-info(8) instead.

(edit) Update: False assumptions on my part, /usr/libdata/pkgconfig is also present in base.txz (I keep this around for my jails and some timestamps) so this isn't caused by pkgconfig. But I still suspect that it doesn't check the package database at all but instead relies on some other mechanics.[/file]


----------



## tobik@ (Mar 1, 2018)

ShelLuser I don't think you understand what pkgconf is used for. It's not related to pkg. pkgconf is a reimplementation (+ library) of freedesktop.org's pkg-config. It's used by third-party software during builds to find the right compiler and linker flags in a cross-platform way. /usr/libdata/pkgconfig/*.pc are files that every normal FreeBSD base installation has.



marcelbonnet said:


> I really don't understand what is happening here.


Can you run 
	
	



```
ktrace pkgconf --exists gtkmm-3.0
kdump > pkgconf.trace
```
 and post pkgconf.trace somewhere. Let's compare them. Here's mine: https://ptpb.pw/hMSF


----------



## ShelLuser (Mar 1, 2018)

tobik@ said:


> ShelLuser I don't think you understand what pkgconf is used for. It's not related to pkg.


I'm aware, I read its manualpage. But this seems to be the behavior the OP was asking about, at least that's how I picked that up.


----------



## tobik@ (Mar 1, 2018)

ShelLuser said:


> I'm aware, I read its manualpage. But this seems to be the behavior the OP was asking about, at least that's how I picked that up.


Hmm, maybe. I think I should take off my debugging hat for today. My response to you sounds way too harsh. Sorry about that


----------



## ShelLuser (Mar 1, 2018)

tobik@ said:


> Hmm, maybe. I think I should take off my debugging hat for today. My response to you sounds way too harsh. Sorry about that


No need, all good.


----------



## marcelbonnet (Mar 2, 2018)

Thanks, guys. You provided me with great help!

ShelLuser , I still learning about C, C++, porting software ... the whole stuff . But, my guess is that pkgconf exists because linux software use it in configure scripts to guess if dependencies are satisfied. Am I right? 

I tried this but pkgconf sounds no sense to me :


```
[@machine pkgconfig]$  pkgconf --exists zlib && echo yay!
yay!
[@machine pkgconfig]$  pkgconf --exists gtkmm-3.0 && echo "hi!"
[@machine pkgconfig]$  pwd
/usr/libdata/pkgconfig
[@machine pkgconfig]$  sudo ln -s /usr/local/libdata/pkgconfig/gtkmm-3.0.pc
[@machine pkgconfig]$  ls
gtkmm-3.0.pc   liblzma.pc     libusb-0.1.pc  libusb-1.0.pc  libusb-2.0.pc  zlib.pc
[@machine pkgconfig]$  pkgconf --exists gtkmm-3.0 && echo "hi!"
[@machine pkgconfig]$
```

tobik@ , my dump is here: https://bin.disroot.org/?6d611fa19d56b7e1#aWZ+kWtToFC2FDVeCE550wQgtlTt0TIX4CtfDHpn354=
I don't know how should I inspect the two dump files ... But I tried searching for _gtkmm_ and found a weird difference between them. Looks like a broken path in my pkgconf:






Cheers,


----------



## tobik@ (Mar 2, 2018)

I think the path difference in Cflags is not the cause of the problem. Though it's certainly weird.

It looks like there is an older gtk3 version installed than actually required. Are your packages up to date? What does `pkg info gtk3 gtkmm30` return?

```
"Package dependency requirement 'atkmm-1.6 >= 2.24.2' could not be satisfied.
Package 'atkmm-1.6' has version '2.22.7', required version is '>= 2.24.2'
Package dependency requirement 'giomm-2.4 >= 2.49.1' could not be satisfied.
Package 'giomm-2.4' has version '2.44.0', required version is '>= 2.49.1'
Package dependency requirement 'pangomm-1.4 >= 2.38.2' could not be satisfied.
Package 'pangomm-1.4' has version '2.36.0', required version is '>= 2.38.2'
Package dependency requirement 'gtk+-3.0 >= 3.22.0' could not be satisfied.
Package 'gtk+-3.0' has version '3.18.8', required version is '>= 3.22.0'
Package dependency requirement 'cairomm-1.0 >= 1.12.0' could not be satisfied.
Package 'cairomm-1.0' has version '1.10.0', required version is '>= 1.12.0'
Package dependency requirement 'gdk-pixbuf-2.0 >= 2.35.5' could not be satisfied.
Package 'gdk-pixbuf-2.0' has version '2.32.3', required version is '>= 2.35.5'
Package dependency requirement 'giomm-2.4 >= 2.49.1' could not be satisfied.
Package 'giomm-2.4' has version '2.44.0', required version is '>= 2.49.1'
Package dependency requirement 'pangomm-1.4 >= 2.38.2' could not be satisfied.
Package 'pangomm-1.4' has version '2.36.0', required version is '>= 2.38.2'
Package dependency requirement 'gtk+-3.0 >= 3.22.0' could not be satisfied.
Package 'gtk+-3.0' has version '3.18.8', required version is '>= 3.22.0'
Package dependency requirement 'cairomm-1.0 >= 1.12.0' could not be satisfied.
Package 'cairomm-1.0' has version '1.10.0', required version is '>= 1.12.0'
Package dependency requirement 'gdk-pixbuf-2.0 >= 2.35.5' could not be satisfied.
Package 'gdk-pixbuf-2.0' has version '2.32.3', required version is '>= 2.35.5'
```


----------



## marcelbonnet (Mar 3, 2018)

Oh man, my ports are not up to date, really. I've been procrastinating ... But, the port that is breaking because of pkgconf has all dependencies satisfied, though .



tobik@ said:


> What does `pkg info gtk3 gtkmm30` return?


It says:

```
$   pkg info gtk3 gtkmm30
gtk3-3.18.8_4
gtkmm30-3.22.0
```

At least, now I understand that pkgconf is a headache and lacks of logic. So, I don't know if its a problem of old pkgconf software, old ports collection, or whatever, but I'm convinced I'll have to create a patch for the configure script that breaks when pkgconf omits the existence of gtkmm and finally compile the desired software.


----------

