pkg-config doesn't see .pc file, even when containing folder is in PKG_CONFIG_PATH - gentoo

I'm running gentoo linux, and I'm trying to get pkg-config to find ntk.pc (ntk being the library I'm trying to link to). Here are the premises:
Output of echo $PKG_CONFIG_PATH:
/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
Output of locate ntk.pc:
/usr/local/lib/pkgconfig/ntk.pc
Output of pkg-config --modversion ntk:
Package ntk was not found in the pkg-config search path.
Perhaps you should add the directory containing `ntk.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ntk' found
Output of cat /usr/local/lib/pkgconfig/ntk.pc:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: ntk
Description: Non ToolKit
Version: 1.3.0
Requires: cairo >= 1.9.0
Requires.private: x11 xft
Libs: -L${libdir} -lntk
Cflags: -I${includedir}/ntk -pthread -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
Any help would be awesome. If you need any more information, please leave a comment and I'll get it to you. Thank you in advance!!

So I fixed it. It turns out that pkg-config didn't understand colon-delimiting like normal bash paths (/usr:/bin...etc), or my comp just needed a restart. Either way assigning $PKG_CONFIG_PATH to /usr/local/lib/pkgconfig works!

Related

How to get pkg-config to use PKG_CONFIG_PATH?

I've written a small library and I'm trying to set it up to be usable with pkg-config, for those in my organization who might need to make use of it later. So my installer places a .pc file in /usr/local/lib/pkgconfig, and I've recently discovered that for some reason this isn't in the default list of directories that pkg-config scans for its pc files, despite /usr/local being the canonical prefix for locally-compiled software. So, I need to add /usr/local/lib/pkgconfig to PKG_CONFIG_PATH.
However, I'm finding that despite claims in the man page, pkg-config's own error message and everywhere online, pkg-config doesn't actually look at PKG_CONFIG_PATH. The error message tells me to add /usr/local/lib/pkgconfig (which contains the .pc file I'm looking for) to PKG_CONFIG_PATH, when I've clearly already done that.
[chris#delphinus-a pkgconfig]$ pwd
/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ ls
libexample.pc
[chris#delphinus-a pkgconfig]$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ pkg-config --cflags libexample
Package libexample was not found in the pkg-config search path.
Perhaps you should add the directory containing `libexample.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libexample', required by 'virtual:world', not found
[chris#delphinus-a pkgconfig]$ echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
[chris#delphinus-a pkgconfig]$ pkg-config --variable pc_path pkg-config
/usr/lib64/pkgconfig:/usr/share/pkgconfig
[chris#delphinus-a pkgconfig]$ pkg-config --version
1.6.3
The contents of libexample.pc:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: libexample
Description: example library.
Libs: -L${libdir} -lpthread -ltimeutil -lczmq -lzmq
Cflags: -I${includedir}
So, if PKG_CONFIG_PATH is indeed the environment variable I need to set, how to I get pkg-config to actually use it? Or what else am I missing here? This is in Fedora 31, FWIW.
Apparently (judging by the very large version number), you're using some other implementation of pkg-config: namely, from this page I gather that it's something called pkgconf and is intended to somehow replace the FDO pkg-config program.
To succeed with PKG_CONFIG_PATH, I suppose, you should install a real pkg-config from FDO, whose version should be in the range of 0.29.x.

How to use openssl in cygwin? [duplicate]

I am trying to compile a small .c file that has the following includes:
#include <openssl/ssl.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <openssl/evp.h>
In the same folder where I have the .c file I have a /openssl with all those files (and more), also in synaptic package manager I see OpenSSL installed, I am trying to compile with this:
gcc -o Opentest Opentest.c -lcrypto
but I always get the errors:
error: openssl/ssl.h: No such file or directory
error: openssl/rsa.h: No such file or directory
error: openssl/x509.h: No such file or directory
error: openssl/evp.h: No such file or directory
The file I want to compile is only a .c file, doesn't have Makefile or ./configure.
I already tried:
env CFLAGS=-I/path/to/openssl/
and tried to compile again but I get the same errors.
What should I do in order to compile with OpenSSL includes?
Your include paths indicate that you should be compiling against the system's OpenSSL installation. You shouldn't have the .h files in your package directory - it should be picking them up from /usr/include/openssl.
The plain OpenSSL package (libssl) doesn't include the .h files - you need to install the development package as well. This is named libssl-dev on Debian, Ubuntu and similar distributions, and openssl-devel on CentOS, Fedora, Red Hat and similar.
Use the -I flag to gcc properly.
gcc -I/path/to/openssl/ -o Opentest -lcrypto Opentest.c
The -I should point to the directory containing the openssl folder.
Use the snippet below as a solution for the cited challenge;
yum install openssl
yum install openssl-devel
Tested and proved effective on CentOS version 5.4 with keepalived version 1.2.7.
You need to include the library path (-L/usr/local/lib/)
gcc -o Opentest Opentest.c -L/usr/local/lib/ -lssl -lcrypto
It works for me.
If the OpenSSL headers are in the openssl sub-directory of the current directory, use:
gcc -I. -o Opentest Opentest.c -lcrypto
The pre-processor looks to create a name such as "./openssl/ssl.h" from the "." in the -I option and the name specified in angle brackets. If you had specified the names in double quotes (#include "openssl/ssl.h"), you might never have needed to ask the question; the compiler on Unix usually searches for headers enclosed in double quotes in the current directory automatically, but it does not do so for headers enclosed in angle brackets (#include <openssl/ssl.h>). It is implementation defined behaviour.
You don't say where the OpenSSL libraries are - you might need to add an appropriate option and argument to specify that, such as '-L /opt/openssl/lib'.
From the openssl.pc file
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenSSL
Description: Secure Sockets Layer and cryptography libraries and tools
Version: 0.9.8g
Requires:
Libs: -L${libdir} -lssl -lcrypto
Libs.private: -ldl -Wl,-Bsymbolic-functions -lz
Cflags: -I${includedir}
You can note the Include directory path and the Libs path from this. Now your prefix for the include files is /home/username/Programming .
Hence your include file option should be -I//home/username/Programming.
(Yes i got it from the comments above)
This is just to remove logs regarding the headers. You may as well provide -L<Lib path> option for linking with the -lcrypto library.
For this gcc error, you should reference to to the gcc document about Search Path.
In short:
1) If you use angle brackets(<>) with #include, gcc will search header file firstly from system path such as /usr/local/include and /usr/include, etc.
2) The path specified by -Ldir command-line option, will be searched before the default directories.
3)If you use quotation("") with #include as #include "file", the directory containing the current file will be searched firstly.
so, the answer to your question is as following:
1) If you want to use header files in your source code folder, replace <> with "" in #include directive.
2) if you want to use -I command line option, add it to your compile command line.(if set CFLAGS in environment variables, It will not referenced automatically)
3) About package configuration(openssl.pc), I do not think it will be referenced without explicitly declared in build configuration.

Package libusb was not found in the pkg-config search path

I have installed pkg-config and libusb through brew
Now if I do
pkg-config --cflags --libs libusb
I get below message
Package libusb was not found in the pkg-config search path. Perhaps
you should add the directory containing `libusb.pc' to the
PKG_CONFIG_PATH environment variable No package 'libusb' found
So I followed this post and did
export
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/Cellar/libusb/1.0.20/lib/pkgconfig"
But I still have the problem. What am I missing?
I am using MAC OSX El Capitan
Just run:
pkg-config --cflags --libs /usr/local/Cellar/libusb/1.0.20/lib/pkgconfig/libusb-1.0.pc
I have the the same problem. This work for me (Ubuntu):
sudo apt-get install libmagickwand-dev
The problem appears to be that homebrew installs libusb with the -1.0 appended to the package and file names. So:
pkg-config --cflags --libs libusb-1.0
will find it, while:
pkg-config --cflags --libs libusb
won't. Since many ./configure and other scripts are looking for it without the -1.0 appended, they fail. To me, this looks like a bug in the homebrew package. Manually creating a non-1.0 named version worked for me, but it's not a very elegant solution.

pkg-config and OSX 10.8, proper PKG_CONFIG_PATH? Missing .pc files?

I installed pkg-config with homebrew in OSX. I'm not sure what I should set my PKG_CONFIG_PATH to? Should it be a combination of /usr/include and /usr/local/include? Even if I use one or the other, I get an error about there not being any .pc files, which I take it would contain info used by pkg-config? Not sure what I'm doing wrong. Help appreciated.
$ pkg-config --libs libxml2
Package libxml2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml2' found
Update:
So maybe I'm asking two different questions. I just curled gsl and ran through the ./configure && make && sudo make install. And with an empty $PKG_CONFIG_PATH I actually got a hit with:
pkg-config --libs gsl
-L/usr/local/lib -lgsl -lgslcblas -lm
But listing /usr/local/lib shows the gsl libs but no .pc files. How come pkg-config works for custom installed packages in OSX but not default installed ones???
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib" >> ~/.bashrc && source ~/.bashrc
to test with say glib:
brew install glib && pkg-config --libs --cflags glib-2.0
should get you the goods:
-I/usr/local/Cellar/glib/2.34.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.34.3/lib/glib-2.0/include -I/usr/local/Cellar/gettext/0.18.2/include -L/usr/local/Cellar/glib/2.34.3/lib -L/usr/local/Cellar/gettext/0.18.2/lib -lglib-2.0 -lintl
I can't add a clarification comment to Nick's answer above, but that is the correct set of paths you need, I have tried with success using homebrew on osx 10.9.1.
If you want this to work with a GUI application such as an IDE, you need to add that path to /etc/launchd.conf.
See the following stack overflow comment:
Setting environment variables in OS X?

provide all (boost,.. whatever) libs to gcc in Freebsd and Ubuntu

What commands are there to tell g++ to use all .so libs of a library like boost or opencv in a system?
I mean not to link it one by one manually like g++ /usr/local/lib/libboost_filesystem.so ....
Forgot such command in ubuntu and don't know what is it in FreeBSD.
Could it be you are looking for pkg-config ? If so, it's in ports in devel.
Usage: pkg-config --libs --cflags libraryName
You need to use -L and -l options with g++

Resources