从eclipse运行时,pkg-config无法找到软件包 [英] pkg-config fails to find packages when run from eclipse

查看:784
本文介绍了从eclipse运行时,pkg-config无法找到软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个令人讨厌的问题。
我在项目中使用pkg-config。它工作正常,但现在它不(不知道已经改变)
当我从内线eclipse与这一行链接:

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

我收到错误:

 在pkg-config搜索路径中找不到程序包opencv。 
也许您应该将包含`opencv.pc'
的目录添加到PKG_CONFIG_PATH环境变量
没有包'opencv'找到

但是当我运行

  pkg-config --libs opencv 

在控制台我得到

 $ $ $ $ $ $ $ $ $ $ $ c> 

这是我会期望的



如果我从控制台编译/链接使用eclipse生成的makefile,它工作正常。



如果我通过在eclipse中设置$ PKG_CONFIG_PATH来指定opencv.pc文件的位置,它可以工作(这是通过附加到$ PKG_SEARCH_PATH)。因此,由于某种原因,当从eclipse调用时,pkg-config不会在默认的/ usr / lib / pkgconfig目录中搜索,但是从命令行调用它时。



可以有人帮我纠正这个,以便pkg-config在从eclipse调用时也会搜索默认的目录? (将默认目录添加到$ PKG_SEARCH_PATH是一个解决方案,但似乎没有必要或正确的方式)



我的设置如下



Eclipse Helios



CDT 7.0



pkg-config版本0.25

解决方案

我找到了解决问题的方法。



不知道为什么,但在eclipse Helios看来,eclipse自动定义一个名为$ PKG_CONFIG_LIBDIR的环境变量。如果此变量存在,pkg-config的默认搜索路径将更改为此变量中的任何一个。解决方案只是取消定义此变量。



从eclipse转到:



项目属性 - > C / C ++构建 - >环境



取消设置变量


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

解决方案

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

这篇关于从eclipse运行时,pkg-config无法找到软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆