2
votes

I have an annoying problem. I use pkg-config in a project. It has worked fine but now it doesn't (dont know that has changed) When I link from inside eclipse with this line:

g++ `pkg-config --libs opencv` -o"RawConverterTgi"  ./main.o

I get the error:

Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

But when I run

pkg-config --libs opencv

in a console I get

-L/usr/local/opencv2.3.1/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

which is what I would expect

If I compile/link from the console by using the makefile that eclipse has generated, it works fine.

If I specify where the opencv.pc file is by setting $PKG_CONFIG_PATH inside eclipse it works (This is done by appending to $PKG_SEARCH_PATH). So for some reason pkg-config doesn't search in the default /usr/lib/pkgconfig directory when invoked from eclipse but when invoked from command line is does.

Can someone help me correct this so that pkg-config searches the default dir also when invoked from eclipse? (adding the default dir to $PKG_SEARCH_PATH is a solution but this doesn't seem to be necessary or the correct way)

My setup is as follows

Eclipse Helios

CDT 7.0

pkg-config version 0.25

1

1 Answers

3
votes

I found the solution to my problem.

I'm not sure why but in eclipse Helios it seems that eclipse automatically defines an environment variable called $PKG_CONFIG_LIBDIR. If this variable exists the default search path for pkg-config is changed to whatever is in this variable. The solution is simply to undefine this variable.

from eclipse go to:

Project properties->C/C++ build -> Environment

to unset the variable