eclipse cdt:从 pkg-config 添加包含路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3816492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:09:25  来源:igfitidea点击:

eclipse cdt: add include path from pkg-config

c++eclipseeclipse-cdteclipse-3.6pkg-config

提问by lurscher

i want to add a dynamic configuration path (generated from pkg-config) to my project. (this is basically for third-party dependencies like boost, so workspace includes is not appropiate, and filesystem include neither because that would be hardcoded and every developer would have to change that manually)

我想向我的项目添加一个动态配置路径(从 pkg-config 生成)。(这基本上适用于像 boost 这样的第三方依赖项,因此工作区包含不合适,文件系统也不包含两者,因为这将是硬编码的,每个开发人员都必须手动更改)

i am on project properties->c++ general->paths and symbols->includes tab->add...->add directory path->variables but i can only select among existing variables, how do i create a new variable dynamically generated from a command line program? like pkg-config --cflags boost-1.43?

我在项目属性-> c++ 常规-> 路径和符号-> 包含选项卡-> 添加...-> 添加目录路径-> 变量但我只能在现有变量中进行选择,如何创建动态生成的新变量从命令行程序?喜欢pkg-config --cflags boost-1.43

this is easy to do in netbeans; you just add the pkg-config commandline with the backquotes in the build additional options and it resolves the build include and even in theory it should update the indexer (although truth be said, last time the indexer was correctly updating from pkg-config was on netbeans 6.8, it has been broken on 6.9 and 6.9.1)

这在 netbeans 中很容易做到;您只需在构建附加选项中添加带有反引号的 pkg-config 命令行,它就可以解决构建包含,甚至理论上它应该更新索引器(尽管说实话,上次索引器从 pkg-config 正确更新是打开的) netbeans 6.8,已在 6.9 和 6.9.1 上被破解)

i read this StackOverflow postbut i still not sure how it helps this specific case

我阅读了这篇 StackOverflow 帖子,但我仍然不确定它如何帮助这个特定案例

i read somewherethat you can use $(shell pkg-config...) to generate environment variables but not sure where to place the command

我在某处读到你可以使用 $(shell pkg-config...) 来生成环境变量,但不确定在哪里放置命令

if there is no easy out of the box solution i'll try the script in this blog post

如果没有简单的开箱即用解决方案,我将尝试使用此博客文章中脚本

btw, i'm using eclipse helios -cdt 7

顺便说一句,我正在使用 eclipse helios -cdt 7

thanks!

谢谢!

回答by Petri Tuononen

Pkg-config support is finally coming to CDT and will be finished on August.

Pkg-config 支持终于来到 CDT,并将于 8 月完成。

http://code.google.com/p/pkg-config-support-for-eclipse-cdt/

http://code.google.com/p/pkg-config-support-for-eclipse-cdt/

回答by thisisme

you can use $(shell pkg-config --cflagsyour_libs) in:

您可以在以下位置使用 $(shell pkg-config --cflagsyour_libs):

Project properties->C/C++ Build->Settings->"Tools Settings" tab->**C Compiler**->Miscellaneous->Other Flags

and

you can use

您可以使用

$(shell pkg-config **--libs** your_libs) 

in

Project properties->C/C++ Build->Settings->"Tools Settings" tab->**C Linker**->Miscellaneous->Other Flags

if the linker doesn't link, make sure (for example in the build console window) that the pkg-config flags appear after the objects to link. you can do this in properties->C/C++ Build->Settings->"Tools Settings" tab->C Linker->Command line pattern moving ${FLAGS}to the end :

如果链接器未链接,请确保(例如在构建控制台窗口中)pkg-config 标志出现在要链接的对象之后。您可以在属性->C/C++ 构建->设置->“工具设置”选项卡-> C 链接器-> 命令行模式移动${FLAGS}到最后执行此操作:

from this (for example) :

从此(例如):

${COMMAND} **${FLAGS}** ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} **${INPUTS}**

to this :

对此:

${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} **${INPUTS} ${FLAGS}**

回答by Mark

In eclipse 4.3.2 at least, it looks as though it's possible to simply add

至少在 eclipse 4.3.2 中,看起来好像可以简单地添加

`pkg-config --libs <mylibname>`

in Project->Properties->C/C++ Build->Settings->GCC {C|C++} Linker->Miscellaneous->Linker Flags

在 Project->Properties->C/C++ Build->Settings->GCC {C|C++} Linker->Miscellaneous->Linker Flags

similarly

相似地

`pkg-config --cflags <mylibname>`

in Project->Properties->C/C++ Build->Settings->GCC {C|C++} Compiler->Miscellaneous->Other Flags

在 Project->Properties->C/C++ Build->Settings->GCC {C|C++} Compiler->Miscellaneous->Other Flags

回答by lurscher

what i found so far is that you can do

到目前为止我发现你可以做到

project-> properties-> c++ build-> build variables

项目-> 属性-> c++ 构建-> 构建变量

add a new variable of string type. Call it whatever you like:

添加一个字符串类型的新变量。你喜欢怎么称呼它:

UNITTEST_CPP_CXXFLAGS

UNITTEST_CPP_CXXFLAGS

then set as its value: $(shell pkg-config --cflags unittest-cpp)

然后设置为它的值: $(shell pkg-config --cflags unittest-cpp)

the go to project properties-> c++ general -> path and symbols, includes. Select languages c++, otherwise it defaults to assembly source file. Click add. On the add directory path, click variables... (because we want to add the variable we have just created)

转到项目属性-> c++ 常规-> 路径和符号,包括。选择语言c++,否则默认为汇编源文件。单击添加。在添加目录路径上,点击变量...(因为我们要添加刚刚创建的变量)

type the name of the variable (UNITTEST_CPP_CXXFLAGS), press enter and ok

输入变量的名称(UNITTEST_CPP_CXXFLAGS),按回车键确定

when you rebuild the result of the shell command is replaced in a -I option (for the gnu gcc toolchain at least), in general pkg-config output might include one or more -I so this won't work. Lets go to c++ build->settings->tool settings->gcc c++ compiler->miscellaneous. In there, add ${UNITTEST_CPP_CXXFLAGS} to the other flags.

当您重建 shell 命令的结果时,将替换为 -I 选项(至少对于 gnu gcc 工具链),通常 pkg-config 输出可能包含一个或多个 -I,因此这将不起作用。让我们转到 c++ build->settings->tool settings->gcc c++ compiler->miscellaneous。在那里,将 ${UNITTEST_CPP_CXXFLAGS} 添加到其他标志。

now the include will be added, but there is no hope of getting the indexer to browse those include!

现在将添加包含,但没有希望让索引器浏览那些包含!

回答by Reinhard Scharf

Use this link at eclipse help/install new spftware. It installs pkg-config. https://raw.githubusercontent.com/TuononenP/pkg-config.p2/master/site.xmlI did find this link in this webpage. https://groups.google.com/forum/#!topic/pkg-config-support-for-eclipse-cdt/HNblZRTKBQQ

在 eclipse 帮助/安装新的 spftware 中使用此链接。它安装 pkg-config。https://raw.githubusercontent.com/TuononenP/pkg-config.p2/master/site.xml我确实在这个网页中找到了这个链接。https://groups.google.com/forum/#!topic/pkg-config-support-for-eclipse-cdt/HNblZRTKBQQ