LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-09-2007, 02:47 AM   #1
queency
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Rep: Reputation: 0
ubuntu linking ??


in my examples i can see the <iostream> tag
how can i know where all header files , tags are located
in the .so files.

example:

I am using wx/wx.h, sqlite3.h, stdlib.h, stdio.h header files and
I cannot link after compiling because i don't know the .so files
that this headers belong to.
gcc -c <mySource> works fine but gcc <mySource> doesn't

where can i find a guide for compiling / linking and .so index
and connect the headers to .so's
 
Old 11-09-2007, 08:24 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by queency View Post
I am using wx/wx.h, sqlite3.h, stdlib.h, stdio.h header files and
I cannot link after compiling because i don't know the .so files
that this headers belong to.
gcc -c <mySource> works fine but gcc <mySource> doesn't
Well, things like stdlib.h and stdio.h are part of your libc (which is automatically linked to by gcc). Things like iostream are part of stdlibc++ (which is automatically linked to by g++). Other headers always come with respective libraries (that’s how you get them in the first place).

For example, sqlite3.h is comes from sqlite. When you installed it, it probably created a symlink (such as /usr/lib/libsqlite3.so) to the real library (in this case, you link with “-lsqlite3”). If you forgot what it was, you can always ask your package manager (assuming you got it from a package repository). Otherwise (if you compiled from source), you can look at the sourcetree (if you kept it around). Otherwise (supposing you compiled with pkg-config enabled), you can use pkg-config.

Other packages are more complicated and might require more libraries. Additionally, there is some cross-platformness associated with them. For example wxWidgets (when run with a gtk backend) has about 10 separate libraries. The libraries might be different if you use the Windows backend. In that case, you use the provided pkg-config wrapper (you could use pkg-config directly, but it might not be portable). For wxWidgets, it’s called wx-config.

So the “best” way to compile your example program is:
Code:
gcc `pkg-config --cflags --libs sqlite3` `wx-config --cflags --libs` -o myExecutable <mySource>
 
Old 11-10-2007, 01:33 AM   #3
queency
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Original Poster
Rep: Reputation: 0
re osor

understood ! thanks very much !
 
  


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
linking? kalleanka Programming 4 11-09-2006 09:16 AM
linking sliders in ubuntu sound mixer zepphead5 Ubuntu 0 08-23-2006 10:23 AM
Problem in using both load time linking and runtime linking durgaprasad_j Linux - General 0 08-01-2006 03:49 AM
Linking LS to 'L' uveraser Linux - General 2 05-20-2004 10:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:22 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