eclipse cdt: add include path from pkg-config

百般思念 提交于 2019-12-03 20:45:09

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/

thisisme

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}**

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

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!