LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   `pkg-config --cflags --libs glib-2.0" -lpthread (https://www.linuxquestions.org/questions/linux-newbie-8/%60pkg-config-cflags-libs-glib-2-0-lpthread-823549/)

Nagababa 08-02-2010 07:38 AM

`pkg-config --cflags --libs glib-2.0" -lpthread
 
Hi

I would be great full to all of you If anyone could explain me these options while compiling.

gcc -o test thread.c `pkg-config --cflags --libs glib-2.0" -lpthread

CincinnatiKid 08-02-2010 07:48 AM

Quote:

Originally Posted by Nagababa (Post 4052599)
Hi

I would be great full to all of you If anyone could explain me these options while compiling.

gcc -o test thread.c `pkg-config --cflags --libs glib-2.0" -lpthread

I think you have a typo, after glib-2.0 you should have a backtick instead of a double quote.

You might look at

Code:

man gcc

man pkg-config

gcc: compiler

-o: output binary file

pkg-config: program to output details, libraries etc to compile a program so that you don't have to type them all out manually.

--cflags
This prints pre-processor and compile flags required to compile the packages on the command line, including flags for all their dependencies. Flags are "compressed" so that each identical flag appears only once. pkg-config exits with a nonzero code if it can't find metadata for one or more of the packages on the command line.

--libs
This option is identical to "--cflags", only it prints the link flags. As with "--cflags", duplicate flags are merged (maintaining proper ordering), and flags for dependencies are included in the output.

-lpthread: link to library pthread during compile time.

Also, take a look at the output for:

Code:

pkg-config --cflags --libs glib-2.0
This will show you what is being linked to during the compilation process. I know that it seems like a lot, especially if you have a background in Windows programming. In Linux you will learn a lot about the compilation/linking process. pkg-config helps out a lot, you are not forced to use it, but if you don't use it, you will have to type all of the output of the above command into your compilation string.

MTK358 08-02-2010 04:21 PM

And it's probably better to use $(command) instead of backticks.

Nagababa 08-03-2010 01:15 AM

Thanks
 
Thanks a lot

Now I have clear picture of it. But still having a doubt....

In man pkg-config it is saying like

--cflags
This prints pre-processor and compile flags required to compile the packages on the command line, including flags for all their dependencies. Flags are "compressed" so that each identical flag appears only once. Where actually it prints the flag??

Might be it is ridiculous question but I want to ask you.

MTK358 08-03-2010 07:29 AM

It just prints them.

$() and backticks capture a program's output and paste it in instead of the $() or backticks.


All times are GMT -5. The time now is 12:03 AM.