public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how to find necessary library
@ 2008-12-12 14:28 Uwe Kiewel
  2008-12-12 14:44 ` John (Eljay) Love-Jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kiewel @ 2008-12-12 14:28 UTC (permalink / raw)
  To: gcc-help

Hi,

is there a option to find automatically the necessary library for 
linking a program?

Example:

If I use #include<math.h> I have to use -lm  Okay, I know this. But, if 
I use #include<sql.h> how do I know which library I need?

TIA,
	Uwe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to find necessary library
  2008-12-12 14:28 how to find necessary library Uwe Kiewel
@ 2008-12-12 14:44 ` John (Eljay) Love-Jensen
  2008-12-12 14:49   ` Uwe Kiewel
  0 siblings, 1 reply; 6+ messages in thread
From: John (Eljay) Love-Jensen @ 2008-12-12 14:44 UTC (permalink / raw)
  To: Uwe Kiewel, GCC-help

Hi Uwe,

Usually a SDK -- like SQL, or SpriteWorld, or SDL, or NCurses -- will have
documentation, which indicates what the the public headers are, and what
library (or libraries) you need to link against.

If the documentation is lacking, then you might need to do some directory
tree spelunking.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to find necessary library
  2008-12-12 14:44 ` John (Eljay) Love-Jensen
@ 2008-12-12 14:49   ` Uwe Kiewel
  2008-12-12 15:40     ` John (Eljay) Love-Jensen
  2008-12-13 16:39     ` Baurzhan Ismagulov
  0 siblings, 2 replies; 6+ messages in thread
From: Uwe Kiewel @ 2008-12-12 14:49 UTC (permalink / raw)
  Cc: GCC-help

John (Eljay) Love-Jensen wrote:
> Hi Uwe,
> 
> Usually a SDK -- like SQL, or SpriteWorld, or SDL, or NCurses -- will have
> documentation, which indicates what the the public headers are, and what
> library (or libraries) you need to link against.

So, in short: I need to now which include/used function needs which 
library?. There is now way in the auto(tool chain) to find automatically 
the dependencies?

TIA,
	Uwe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to find necessary library
  2008-12-12 14:49   ` Uwe Kiewel
@ 2008-12-12 15:40     ` John (Eljay) Love-Jensen
  2008-12-13 16:39     ` Baurzhan Ismagulov
  1 sibling, 0 replies; 6+ messages in thread
From: John (Eljay) Love-Jensen @ 2008-12-12 15:40 UTC (permalink / raw)
  To: Uwe Kiewel; +Cc: GCC-help

Hi Uwe,

> I need to know which include/used function needs which library?

Yes, that is correct.

If you use the symbols from NCurses (and its #include's) in your source
code, you need to specify -lncurses (for libncurses.a) on your link line.

> There is no way in the auto(tool chain) to find automatically the
dependencies?

Automatically... no.

You can use grep for include preprocessor directives.

You can look at the missing symbols that the linker indicates, and use that
as a clue as to which libraries are missing.

You can use tools like ldd or nm or otool to look at symbols in executables,
object files and libraries.

If this seems a bit archaic, brittle, and/or arcane, I agree.  The tools
were devised in the era of much smaller machines, and the programmer was
expected to know what libraries he was pulling into his project.

It's a pain point, no doubt.  And the solutions I've seen just moved the
brittleness around.

Solutions that actually solve the problem involve moving entirely to a new
language and IDE.

I'm a C++ guy through-and-through who uses Vim as my IDE, but I've had a
very pleasant excursion with Java using the Eclipse IDE.  In some problem
domains, Java is the best tool of choice (in my humble opinion) -- such as
enterprise software (J2EE).

But that is a rather drastic solution, and may-or-may-not be an option.

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to find necessary library
  2008-12-12 14:49   ` Uwe Kiewel
  2008-12-12 15:40     ` John (Eljay) Love-Jensen
@ 2008-12-13 16:39     ` Baurzhan Ismagulov
  2008-12-14  3:19       ` Marc Weber
  1 sibling, 1 reply; 6+ messages in thread
From: Baurzhan Ismagulov @ 2008-12-13 16:39 UTC (permalink / raw)
  To: gcc-help

On Fri, Dec 12, 2008 at 03:48:49PM +0100, Uwe Kiewel wrote:
> So, in short: I need to now which include/used function needs which 
> library?. There is now way in the auto(tool chain) to find automatically 
> the dependencies?

If you are interested in deploying on several platforms, or on an
open-source platform, or publishing the source of your program, you may
in addition find out that there are several independent packages
providing the same API. As Eljay said, the burden of finding out the
right libraries to link with still lies on you (but then, how did you
find out the right header to use?); after you know which headers and
libraries you need, you can automate the checking whether they are
usable and where they are located by using a tool like autoconf.

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to find necessary library
  2008-12-13 16:39     ` Baurzhan Ismagulov
@ 2008-12-14  3:19       ` Marc Weber
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Weber @ 2008-12-14  3:19 UTC (permalink / raw)
  To: gcc-help

On Sat, Dec 13, 2008 at 05:38:56PM +0100, Baurzhan Ismagulov wrote:
> On Fri, Dec 12, 2008 at 03:48:49PM +0100, Uwe Kiewel wrote:
> > So, in short: I need to now which include/used function needs which 
> > library?. There is now way in the auto(tool chain) to find automatically 
> > the dependencies?

You can use packaging tools to list all packages containing a header
file. At least this gives you some hints. If you haven't installed the
package you can use databases such as rpmseek.com

Of course you still must verify that you got the corrrect header file
and test your application!

Marc Weber

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-12-14  3:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-12 14:28 how to find necessary library Uwe Kiewel
2008-12-12 14:44 ` John (Eljay) Love-Jensen
2008-12-12 14:49   ` Uwe Kiewel
2008-12-12 15:40     ` John (Eljay) Love-Jensen
2008-12-13 16:39     ` Baurzhan Ismagulov
2008-12-14  3:19       ` Marc Weber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).