pkg-config file openmp dependency - pkg-config

I want to write a pkg-config for a library that uses openmp internally.
My .pc file reads
prefix=/usr/local
exec_prefix=/usr/local
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: LightFEM
Description:
Version: 1.0.0
Requires: openmp
Libs: -L${libdir} -lLightFEM
Cflags: -I${includedir}
However pkg-config returns the following error
Package openmp was not found in the pkg-config search path.
Perhaps you should add the directory containing `openmp.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openmp', required by 'LightFEM', not found
How sould I write my .pc file ?

Related

configure script cannot find libxml2 on mac

when I execute
./configure
...
checking for libxml-2.0... no
configure: error: Library libxml2 not found, install library or build without (using --disable-xml).
I installed libxml2 with brew and checked a lot of articles, but nothing helped so far.
UPDATE
./configure --help
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
libxml2_CFLAGS
C compiler flags for libxml2, overriding pkg-config
libxml2_LIBS
linker flags for libxml2, overriding pkg-config
homebrew installs libxml2 as "keg only" which means it is not symlinked to the normal /usr/local/include and /usr/local/lib directories... which means nothing can find it without help. You can get all the above info by running:
brew info libxml2
If you run:
brew ls libxml2
it will tell you the full paths to all the files in that package.
If you also run:
./configure --help
it should tell you what environment variables you need to set in order to find libxml2 So, armed with these last two pieces of info, you should be able to work out what you need to set and how.
I note there is a pkg-config file listed for libxml2 by homebrew at:
/usr/local/Cellar/libxml2/2.9.10/lib/pkgconfig/libxml-2.0.pc
which is also available via a non-version-specific symlink as:
/usr/local/opt/libxml2/lib/pkgconfig/libxml-2.0.pc
so, if you have installed pkg-config with homebrew, like this:
brew install pkg-config
the solution may be just to add the path for that to your PKG_CONFIG_PATH with:
export PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
and then to rerun your configure script.
Note: It is only after installing pkg-config (via brew) that homebrew will display pkg-config related "caveats" for many affected packages e.g. libffi:
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.
For compilers to find libffi you may need to set:
export LDFLAGS="-L/usr/local/opt/libffi/lib"
For pkg-config to find libffi you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
Unfortunately, however, this appears not to be the case for libxml2 for some reason. (Related homebrew issue: "libxml2 install path".)

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.

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

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!

Finding Libraries using pkg-config in Windows

I am, trying to find the gstreamer lib in windows (msvc) using pkg-config
pkg-config gstreamer-0.10 --cflags --libs
but i am getting any result like this
Package gstreamer-0.10 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gstreamer-0.10.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gstreamer-0.10' found
a .pc like is created when a library is installed (automatically through the use of an RPM, deb, or other binary packaging system or by compiling from the source).I can't find the .pc file in my gstreamer directory.
Should i just create a .pc file with all the necessary details.
prefix=C:\Program Files (x86)\OSSBuild\GStreamer\v0.10.7
exec_prefix=${prefix}
libdir=${exec_prefix}\lib
includedir=${prefix}\sdk\include\gstreamer-0.10
toolsdir=${exec_prefix}\bin
pluginsdir=${exec_prefix}\lib\gstreamer-0.10
datarootdir=${prefix}\share
datadir=${datarootdir}
girdir=${datadir}/gir-1.0
typelibdir=${libdir}/girepository-1.0
Name: GStreamer
Description: Streaming media framework
Requires: glib-2.0, gobject-2.0, gmodule-no-export-2.0, gthread-2.0, libxml-2.0
Version: 0.10.35
Libs: -L${libdir} -lgstreamer-0.10
Cflags: -I${includedir}
or there is any other way to do this or Am i missing somthing?
Hope you can help.Thankz for taking the time to read the problem.
Well i am doing this to find solution why i am getting not found message in my waf configure for gstreamer
conf.check_cfg(atleast_pkgconfig_version='0.0.0')
conf.check_cfg(package='gstreamer-0.10', uselib_store='GSTREAMER', args='--cflags --libs', mandatory=True)
the code works in linux and is supposed to work in windows too.
ADDED LATER
Well making the .pc and setting a path of the .pc dir to the PKG_CONFIG_PATH environment variable does the trick.Its not hard do it
Check out this out. Thankz for readings and helping me..:)
pkg-config is a great tool but unfortunately on Windows (vs. UNIX) there is no standard executable PATH or PKG_CONFIG_PATH.
While you can revert to defining options --with-gstreamer-include-dir ... --with-gstreamer-lib-dir ... and avoid the pkg-config dependency, you can also use --pkgconfig-exe c:\path\to\pkg-config.exe --pkgconfig-path c:\path\to\gstreamer;c:\path\to\otherlib, which will help having a good-looking wscript, especially when using a lot of pkg-config libs.
The typical Win32 user may have issues setting PKG_CONFIG_PATH and PATH directly or stumbling onto a cryptic "not found" error and then checking config.log.
If you do add the windows-specific pkg-config options, it might be interesting for everybody.
You could write a pkgconfig_opts tool and submit it as a waf extra.

Resources