LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2010, 07:38 AM   #1
Nagababa
LQ Newbie
 
Registered: Jul 2010
Posts: 15

Rep: Reputation: 0
`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
 
Old 08-02-2010, 07:48 AM   #2
CincinnatiKid
Member
 
Registered: Jul 2010
Posts: 454

Rep: Reputation: 47
Quote:
Originally Posted by Nagababa View Post
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.

Last edited by CincinnatiKid; 08-02-2010 at 07:56 AM. Reason: Forgot something
 
1 members found this post helpful.
Old 08-02-2010, 04:21 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
And it's probably better to use $(command) instead of backticks.
 
1 members found this post helpful.
Old 08-03-2010, 01:15 AM   #4
Nagababa
LQ Newbie
 
Registered: Jul 2010
Posts: 15

Original Poster
Rep: Reputation: 0
Thumbs up 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.
 
Old 08-03-2010, 07:29 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
It just prints them.

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pkg-config problem at Xorg7.1 libs c31c Linux From Scratch 5 12-25-2010 09:58 AM
Cent OS GLib 2.12.3 pkg-config --modversion glib-2.0' returned 2.22.2 Styles Linux - Distributions 1 10-09-2009 03:12 AM
'pkg-config --modversion glib-2.0' returned 2.16.3, but GLIB (2.14.6) pgb205 Linux - Software 7 05-17-2008 03:21 PM
pkg-config glib gtk gdk Peterius Linux - Software 6 05-11-2007 02:38 AM
pkg-config and glib: Uninstalling Old and Installing New CooManChu Linux - Software 6 09-06-2005 03:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration