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

发布于 2024-09-24 23:54:20 字数 941 浏览 2 评论 0原文

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

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

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

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

我阅读的这个特定案例 某处,您可以使用 $(shell pkg-config...) 生成环境变量,但不确定在哪里放置命令(

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

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

谢谢!

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)

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?

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)

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

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

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

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

↙厌世 2024-10-01 23:54:20

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

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

如果链接器未链接,则

可以使用

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

in

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

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

从这个(例如):

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

到这个:

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

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

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 :

from this (for example) :

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

to this :

${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} **${INPUTS} ${FLAGS}**
烟雨扶苏 2024-10-01 23:54:20

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

http://code.google.com/p/pkg-配置支持-for-eclipse-cdt/

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

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

巷子口的你 2024-10-01 23:54:20

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

`pkg-config --libs <mylibname>`

添加
项目 -> 属性 -> C/C++ Build -> 设置 -> GCC {C|C++} Linker -> Miscellaneous -> Linker

类似

`pkg-config --cflags <mylibname>`

Flags
项目->属性->C/C++ 构建->设置->GCC {C|C++} 编译器->杂项->其他标志

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

`pkg-config --libs <mylibname>`

in
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

怀中猫帐中妖 2024-10-01 23:54:20

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

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

添加一个字符串类型的新变量。
随意称呼它:

UNITTEST_CPP_CXXFLAGS

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

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

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

重建时shell命令的结果将被替换为-I 选项(至少对于 gnu gcc 工具链),一般来说 pkg-config 输出可能包含一个或多个 -I,所以这不起作用。让我们进入c++构建->设置->工具设置->gcc c++编译器->杂项。在其中,将 ${UNITTEST_CPP_CXXFLAGS} 添加到其他标志。

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

what i found so far is that you can do

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

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

UNITTEST_CPP_CXXFLAGS

then set as its value:
$(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)

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

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.

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

Spring初心 2024-10-01 23:54:20

使用 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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文