Author Topic: Adding pkg_config to Code:Blocks linker  (Read 9691 times)

Offline JulyJim

  • Multiple posting newcomer
  • *
  • Posts: 11
Adding pkg_config to Code:Blocks linker
« on: November 22, 2016, 05:38:35 pm »
I have "openCV.pc" package build by pkg_config and understood that one can add "Other linker options" to linker , but not sure how.
Can anybody give a greenhorn a hand with exact syntax?
Help is much appreciated.


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Adding pkg_config to Code:Blocks linker
« Reply #1 on: November 22, 2016, 06:08:08 pm »
Just add the "pkg-config" line to the other linker (and probably compiler)-options, just as you do it on the command-line, but surround it with backticks ("`"), e.g.
Code
`pkg-config glib-2.0 --libs`

Offline JulyJim

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Adding pkg_config to Code:Blocks linker
« Reply #2 on: November 22, 2016, 10:47:57 pm »
OK, I have added it to linker and did not see any progress messages indicating it was used.
In theory it should not be used in compiler - it is a liker job to get the libraries.
But I'll give it a shot.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Adding pkg_config to Code:Blocks linker
« Reply #3 on: November 22, 2016, 10:57:26 pm »
Use the compiler section for compiler-flags and the linker section for linker-stuff.
And what I forgot to write: you might have to close C::B and reopen it, to make it work.

Offline JulyJim

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Adding pkg_config to Code:Blocks linker
« Reply #4 on: November 23, 2016, 03:22:15 pm »
In theory it should not be used in compiler - it is a liker job to get the libraries.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Adding pkg_config to Code:Blocks linker
« Reply #5 on: November 23, 2016, 03:32:12 pm »
In theory it should not be used in compiler - it is a liker job to get the libraries.

So, you have no real knowledge of pkg_config it has options to output compiler flags that might be needed!
In the compiler extra settings area.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JulyJim

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Adding pkg_config to Code:Blocks linker
« Reply #6 on: November 23, 2016, 06:03:44 pm »
I have some knowledge about pkg_config and there is no need to be so snippy about it.
( Read the rules before you post )

If I had 100% would I ask for help? 

The question still remain - how to add these "flags" to GCC compiler.
Can you post an example ?
Thanks


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Adding pkg_config to Code:Blocks linker
« Reply #7 on: November 23, 2016, 06:46:04 pm »
Can you post an example ?

Is my previous post hidden for you ?

I quotee it here:
Just add the "pkg-config" line to the other linker (and probably compiler)-options, just as you do it on the command-line, but surround it with backticks ("`"), e.g.
Code
`pkg-config glib-2.0 --libs`

Or what do you mean with example ?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Adding pkg_config to Code:Blocks linker
« Reply #8 on: November 23, 2016, 08:37:19 pm »
FYI: You are on the Internet; it has search engines!
https://people.freedesktop.org/~dbn/pkg-config-guide.html

Learn to use them. I use https://www.google.com

You really need to learn about your OS Operating System and the tools in it!

You are appearing to be a troll to me. I do NOT feed trolls.

Tim S.
 
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JulyJim

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Adding pkg_config to Code:Blocks linker
« Reply #9 on: November 23, 2016, 08:49:03 pm »
Tim, you could be more helpful but I really expect way to much from forums.
Obviously situation normal - it is my fault I dare to ask here,


I have made some progress but still cannot get the pkg-config to link the libraries it finds to linker.
Just to clear things up - the question was not HOW to MAKE packages - the question was how to add them to the linker.
My GCC linker won't link if the  library string is not prefixed with ":"  so maybe pkg-config is wrong app to use, 


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Adding pkg_config to Code:Blocks linker
« Reply #10 on: November 23, 2016, 10:11:28 pm »
Tim, you could be more helpful but I really expect way to much from forums.
Obviously situation normal - it is my fault I dare to ask here,


I have made some progress but still cannot get the pkg-config to link the libraries it finds to linker.
Just to clear things up - the question was not HOW to MAKE packages - the question was how to add them to the linker.
My GCC linker won't link if the  library string is not prefixed with ":"  so maybe pkg-config is wrong app to use,
Please copy and paste the pkg-config-line from the linker section and write exactly where you added it, please copy and paste also the "Build log" (not the "Build messages")  from a rebuild (clean and build), after saving the project, closing and reopening C::B.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Adding pkg_config to Code:Blocks linker
« Reply #11 on: November 23, 2016, 11:36:38 pm »
Obviously situation normal - it is my fault I dare to ask here,
Obviously it is your fault, because you have the problem ;)

So now lets give some useful comment:
NOTE: i am not a advanced user of pkg-config...

pkg-config has two important command  line options:
Code
pkg-config --cflags
and
Code
pkg-config --libs

--cflags will return all needed compiler flags like include paths and defines.
you have to add this command in the compiler options
Project->Build options
On the left side select your target, or your project the project name if you want to apply the option globally
then go to: compiler settings->Other compiler options. There you add the appropriate pkg-config command:
Code
`pkg-config opencv --cflags`
Now we need to apply the --libs flag.  --libs will return the library paths and the libraries needed. For this go to the "linker settings" tab and under "other linker options" add
Code
`pkg-config opencv --libs`
Now confirm this dialog with OK. You may have to restart codeblocks, because c::b cashes all backtick results for speed up reasons and only loads them on start up...

If you still have problems check if pkg-config opencv --cflags and pkg-config opencv --libs gives the correct results on your command line program.
If it still don't work you want future help from this forum read this and follow the steps described, especially the build log thing, because we are not able to help you with this few information you provided until now
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Quote
OK, I have added it to linker and did not see any progress messages indicating it was used.
In theory it should not be used in compiler - it is a liker job to get the libraries.
But I'll give it a shot.
this does not add any usefull information. The build log on the other side tells us nearly all we need..

All this is no magic and can easily be found with google...

I hope this helps
greetings