Where do the pkg-config targets get defined? - c

When I perform the command
pkg-config --variable pc_path pkg-config
The output is
/usr/lib64/pkgconfig:/usr/share/pkgconfig
However, there are two other pkgconfig directories on my system: /usr/lib/pkgconfig and /usr/local/lib/pkgconfig
If I try
echo $PKG_CONFIG_PATH
the result is
Undefined variable
I also tried to
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
but the response was
export: Command not found.
Now, I have built Gstreamer on multiple occasions and it will put the
metadata files (gstreamer-1.0.pc) into the other pkgconfig folder (usr/local/lib/pkgconfig). (I have been able to overcome this issue by modifying the configure file, changing lib to lib64 at the libdir definition.) But I would rather understand my system rather than try work-arounds.
So two questions: where does the pkg-config program get its target directories?
And why and how do the metadata files get put into a directory that is not apparently indicated by the pkg-config program?

Since the command is not working because that variable was not present
first check that variable is there or not for to do this
execute command
env
root#localhost:/etc/apt# env
if the path is not declare in env
then do something like
root#localhost:/etc/apt# PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
root#localhost:/etc/apt# export PKG_CONFIG_PATH
root#localhost:/etc/apt# echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig
root#localhost:/etc/apt# env
Hope this will work for you
for any further help please post the queries with error

When you install a foo package, foo package has an appropriate foo.pc that gets installed in the default pkgconfig directories. If a package puts its *.pc file in a custom location, as you already know, you should set your PKG_CONFIG_PATH accordingly. So, the pkg-config will not only look in the default directories, but also in the custom path you specified in PKG_CONFIG_PATH. This guide explains it well:
pkg-config guide

Related

how to add directory to search path in msys2?

I am trying to install GTK 3 for C using this tutorial
after following the full install instructions and trying to build a simple program using this I was met with
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0', required by 'virtual:world', not found
error. So I re did all the steps and noticed
Plus after installing the toolchain base-devel for C,C++ I checked if the old problem stayed using pkg-config --modversion gtk+3.0 I found this command here
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0', required by 'virtual:world', not found
same issue. So my question is, Is there a way to add C:/msys64/mingw64/share/ to search path?
Use this command:
$ export PATH=$PATH:/c/msys64/mingw64/share

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

I am using check package in netbeans for C programming, But I receive this error from netbeans:
Package check was not found in the pkg-config search path.
Perhaps you should add the directory containing `check.pc'
to the PKG_CONFIG_PATH environment variable
No package 'check' found
In the terminal if I insert this line:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
and then
pkg-config --modversion check
it can find the check package, but in netbeans I still get the same error.
What should I do?
Thanks in advance
If you use OS X Mavericks,
Then download packages "check", "valgrind", "gcc" and "pkg-config" through the HomeBrew.
then edit /etc/launchd.conf and add there setenv PATH <your $PATH> Substitute with your real path. In this file no $HOME or such can't be used. This path should include gcc, check and valgrind. For this to take effect you need to restart your computer.
For me this worked:
$ cat /etc/launchd.conf
setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Cython not finding shared library

My issue started identical to this one: Python executable not finding libpython shared library
I updated .bashrc with export LD_LIBRARY_PATH=$HOME/local/lib/python/2.7.6/lib and things were fine. Python works, and I installed pip. But now, I'm running into something similar when installing cython with pip. I get this error message when I execute pip install cython:
gcc -pthread -shared build/temp.linux-x86_64-2.7/tmp/pip_build/cython/Cython/Plex/Scanners.o -L. -lpython2.7 -o build/lib.linux-x86_64-2.7/Cython/Plex/Scanners.so
/usr/bin/ld: cannot find -lpython2.7
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
I cannot add $HOME/local/lib/python/2.7.6/lib to /etc/ld.so.conf and run ldconfig as I do not have root. I was under the impression that setting the LD_LIBRARY_PATH was the way around this, but this appears to not be true for compilation. Is there a way to get the compiler to see this local library without running root commands?
Update:
The LD_LIBRARY_PATH is only used by the dynamic loader at runtime, not at build time, so that is not the issue. The issue is that you forgot to put the -L/path/to/pylib before the -l. I've never had to use LIBRARY_PATH because a build requires path extension that is specific to a given build, so you never set LIBRARY_PATH you just use -L. You would only set if if you are going to regularly do builds that use a specific library, and even then I find it better to use -L because sooner or later this will cause linker to find the wrong lib and by then you will have forgotten that it's because LIBRARY_PATH is set permanently.
There are many ways to set -L values in a build: if you run the compiler from command line you don't need that env var, you just specify as many -L as required as part of the command; if you use a makefile, you edit whatever make variable you are using, such as CFLAGS or other, different platforms have different conventions. So whereas setting -L directly will always work, setting CFLAGS will only work if that is the variable used by the makefile.
Now this is a python installation so where to set this may not be obvious, but I am sure there is another way than setting LIBRARY_PATH. In principle any python package you install, if it involves compilation of C++ modules, could require edit of the setup.py to set library paths. For example
Extension(...,
library_dirs=['/usr/X11R6/lib'],
...)
Since you mention nympy, another place to set this might be in site.cfg (see Supplying NumPy site.cfg arguments to pip).
Old (wrong) answer:
Set your LD_LIBRARY_PATH in your bash console. If this doesn't work then it's because you have the wrong path: check by echoing the environment var.
Once you get that to work, edit your .bashrc or .profile then exit your shell and restart it. Echo the env var to verify that contains the part you added.
Also, ensure that you are appending to the path rather overwriting it:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/...
export LD_LIBRARY_PATH
Because python lib might depend on .so in other folders, if the linker can't find them it may appear as though it is the python lib that was not found. This is not explained on the page you linked to in your question.
OK after some more digging I found this: LD_LIBRARY_PATH vs LIBRARY_PATH
Setting LIBRARY_PATH to the same path as LD_LIBRARY_PATH made the compiler aware of the python lib. cython/numpy/scipy all built and installed no problem afterwords.

How to add library to PKG-CONFIG Mac

I am trying to get flikcurl to sync with pkg-config. I tried installing it via macports, but it results in an error during build.
I am able to find the flickurl.a static library and the src headers.
My question is, how do I add these to the PKG_CONFIG path?
Thanks!
If flickcurl.pc is in the directory /p/a/t/h, you need to add /p/a/t/h to PKG_CONFIG_PATH, which is a colon separated list of all the places that pkg-config will look for pc files:
$ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}/p/a/t/h

C Socket Programming with CygWin

Hi
I'm trying to write a little server / client program in C using CygWin, problem is, the gcc compiler in Cygwin doesn't seem to contain the standard headers assosiated with socket-programming. When trying to compile my server program, i get:
netinet/in.h: No such file or directory
sys/socket.h: No such file or directory
netdb.h: No such file or directory
Are these three headers located elsewhere in the CygWin-enviorment?
I also had same problem.. i was googling for hours and finally found this... thanks to ralph...
https://ralphexe.wordpress.com/2015/09/09/run-unix-socket-program-in-windows-using-cygwin/
For socket commands you have to include some of the packages in cygwin while installing...
(If you have installed try reinstalling ...)
During the installation :
In "SELECT PACKAGES " phase of installation.
Expand DEVEL
select GNU compilers for c and c++
4.And click next and complete the installation.
NOW, try with a socket program involving sys/socket.h ...
I HOPE IT WILL WORK ... :-)..
Try using the -I compiler command line option to specify a path to the header files.
My local reference states
-I dir
Add the directory dir to the list of directories to be searched for
header files. Directories named by -I are searched before the
standard system include directories. If the directory dir is a
standard system include directory, the option is ignored to ensure
that the default search order for system directories and the
special treatment of system headers are not defeated .
At least on my cygwim they are in
/usr/include/sys and /usr/include/netinet
I also had the same problem.
I've resolved to review the compile options.
NG:
$ gcc -mno-cygwin -o echo_server.exe echo_server.c
echo_server.c:12:43: sys/socket.h: No such file or directory
echo_server.c:13:24: netinet/in.h: No such file or directory
OK:
$ gcc -o echo_server.exe echo_server.c
I had this problem for days with the library apophenia .
so make sure the libraries you've installed have first been configured with a simple command
./configure
once configured use the following commands to build , Install and check the libraries
all- Builds libraries
install- installs libraries
check-tests the libraries
doc- generate documentation via doxygen
Hope it helps. :)

Resources