eclipse cdt: add include path from pkg-config
Asked Answered
B

5

3

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!

Being answered 28/9, 2010 at 19:49 Comment(0)
A
3

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/

Archduke answered 12/5, 2011 at 13:29 Comment(3)
good news!! thanks for the info.. i assume this will automagically hook up with the code completion indexer?Being
Let's see. The current plan is that available packages are shown on property page and user needs to check the needed packages. The options are then fed automatically to compiler and linker. Sure it would be great if Eclipse would figure out itself which packages are used based on source code. I keep this on my mind. Any other suggestions are welcome.Archduke
Hi, I have some great news. Now you can test the beta version which should work fine. marketplace.eclipse.org/content/pkg-config-support-eclipse-cdt Just navigate to Project properties -> C/C++ Build -> Settings -> Pkg-config and check packages you need. Feedback is appreciated.Archduke
D
4

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}**
Disgruntle answered 30/12, 2012 at 19:0 Comment(0)
A
3

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/

Archduke answered 12/5, 2011 at 13:29 Comment(3)
good news!! thanks for the info.. i assume this will automagically hook up with the code completion indexer?Being
Let's see. The current plan is that available packages are shown on property page and user needs to check the needed packages. The options are then fed automatically to compiler and linker. Sure it would be great if Eclipse would figure out itself which packages are used based on source code. I keep this on my mind. Any other suggestions are welcome.Archduke
Hi, I have some great news. Now you can test the beta version which should work fine. marketplace.eclipse.org/content/pkg-config-support-eclipse-cdt Just navigate to Project properties -> C/C++ Build -> Settings -> Pkg-config and check packages you need. Feedback is appreciated.Archduke
S
2

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

Shorn answered 17/12, 2014 at 9:59 Comment(0)
B
1

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!

Being answered 1/10, 2010 at 22:44 Comment(0)
D
0

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

Doughboy answered 5/1, 2020 at 0:18 Comment(1)
Judging from the typo in this post and from the existence of your other post on this page, you are not aware of the possiblity to edit your own posts. Please take the tour.Tachyphylaxis

© 2022 - 2024 — McMap. All rights reserved.