简体   繁体   English

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

[英]eclipse cdt: add include path from pkg-config

i want to add a dynamic configuration path (generated from pkg-config) to my project.我想向我的项目添加一个动态配置路径(从 pkg-config 生成)。 (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) (这基本上适用于像 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?我在项目属性-> C++ 常规-> 路径和符号-> 包含选项卡-> 添加...-> 添加目录路径-> 变量但我只能在现有变量中进行选择,如何创建动态生成的新变量从命令行程序? like pkg-config --cflags boost-1.43 ?pkg-config --cflags boost-1.43

this is easy to do in netbeans;这在 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)您只需在构建附加选项中添加带有反引号的 pkg-config 命令行,它就可以解决构建包含,甚至理论上它应该更新索引器(尽管说实话,上次索引器从 pkg-config 正确更新是打开的) netbeans 6.8,已在 6.9 和 6.9.1 上损坏)

i read this StackOverflow post but i still not sure how it helps this specific case我阅读了这篇 StackOverflow 帖子,但我仍然不确定它如何帮助这个特定案例

i read somewhere that 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!谢谢!

you can use $(shell pkg-config --cflags your_libs) in:您可以在以下位置使用 $(shell pkg-config --cflags your_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.如果链接器未链接,请确保(例如在构建控制台窗口中)pkg-config 标志出现在要链接的对象之后。 you can do this in properties->C/C++ Build->Settings->"Tools Settings" tab-> C Linker ->Command line pattern moving ${FLAGS} to the end :您可以在 properties->C/C++ Build->Settings->"Tools Settings" tab-> C Linker ->Command line pattern 移动${FLAGS}到最后执行此操作:

from this (for example) :由此(例如):

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

to this :对此:

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

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/

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

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.转到项目属性-> c++ 常规-> 路径和符号,包括。 Select languages c++, otherwise it defaults to assembly source file.选择语言c++,否则默认为汇编源文件。 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输入变量的名称(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.当您重建 shell 命令的结果时,将替换为 -I 选项(至少对于 gnu gcc 工具链),通常 pkg-config 输出可能包含一个或多个 -I,因此这将不起作用。 Lets go to c++ build->settings->tool settings->gcc c++ compiler->miscellaneous.让我们转到 c++ build->settings->tool settings->gcc c++ compiler->miscellaneous。 In there, add ${UNITTEST_CPP_CXXFLAGS} to the other flags.在那里,将 ${UNITTEST_CPP_CXXFLAGS} 添加到其他标志。

now the include will be added, but there is no hope of getting the indexer to browse those include!现在将添加包含,但没有希望让索引器浏览那些包含!

Use this link at eclipse help/install new spftware.在 eclipse 帮助/安装新的 spftware 中使用此链接。 It installs pkg-config.它安装 pkg-config。 https://raw.githubusercontent.com/TuononenP/pkg-config.p2/master/site.xml I did find this link in this webpage. https://raw.githubusercontent.com/TuononenP/pkg-config.p2/master/site.xml我确实在这个网页中找到了这个链接。 https://groups.google.com/forum/#!topic/pkg-config-support-for-eclipse-cdt/HNblZRTKBQQ https://groups.google.com/forum/#!topic/pkg-config-support-for-eclipse-cdt/HNblZRTKBQQ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM