Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-amd64
Navigation:
Lists: gentoo-amd64: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-amd64@g.o
From: Duncan <1i5t5.duncan@...>
Subject: Re: How does gcc find a library?
Date: Sun, 17 May 2009 20:13:22 +0000 (UTC)
Mark Knecht <markknecht@...> posted
5bdc1c8b0905170849j3e0198ebrf29bc2042dda7ee4@..., excerpted
below, on  Sun, 17 May 2009 08:49:13 -0700:

> Hi,
>    I'm trying to compile a new piece of software for MythTV hardware
> support that's not in portage. I'm not a programmer so I'm woefully
> uneducated in this area but how does gcc find a library that a piece of
> code is requiring?

Well, I'm not a programmer either, but I think I understand a bit about 
this just from troubleshooting various ebuilds over time.  YMMV, but the 
below is what I'd try.

gcc looks in various standard system locations (/usr/include, among 
others) automatically for the header files, which tell it the interfaces 
the library supplies.  The interfaces consist of the the functions, etc, 
along with the parameters they take, their orders and their types (int, 
string pointer, whatever).

For header files not found in the standard locations and not in the 
working dir that's being compiled, gcc has the -I<includedir> parameter, 
among others.

Then for linking, there's  -L<linkdir>, if you find you need it later.

>    My code setup is this:
> 
> /home/mark/scte65scan-0.2
> /home/mark/scte65scan-0.2/libhdhomerun

> The code all exists in the scte65scan directory. The required library is
> in libhdhomerun.
> 
>    When I attempt to build the code I get the error message:
> 
> mark@Sector9 ~/scte65scan-0.2 $ make -f Makefile.hdhr cc -O2 -DHDHR -c
> tunerdmx.c -o tunerdmx.o tunerdmx.c:39:23: error: hdhomerun.h: No such
> file or directory

>    So it seems it cannot find the library because hdhomerun.h is in
> the libhdhomerun diectory:

>    The tunerdmx.c program has an include for hdhomerun:
> 
> #ifdef HDHR
> #include "hdhomerun.h"
> 
> which is what I guess is kicking off the problem. The makefile looks
> like this:
> 
> mark@Sector9 ~/scte65scan-0.2 $ cat Makefile.hdhr
> HDHR_DIR=./libhdhomerun

That part looks right, since it's a subdir, and the (snipped) LIBOBJS 
point into it as expected.

> CFLAGS += -O2 -DHDHR
> LDFLAGS += -lpthread

>    So, how do I tell gcc that the library is here so it can build it?

Add to that CFLAGS line: -I./libhdhomerun .  See if that helps.  You can 
try the absolute form too (/home/mark...) but that can cause problems if 
things are moved around, later.  The relative form should help avoid 
those problems.

If you later get hungup in linking, there's the -L<dir> parameter for 
that, too, but I'd not add it until it looks like it's needing it.

As I said above, this is troubleshooting level knowledge.  Try it and see 
if it works more than really understanding the full implications, tho I 
believe I understand why it /should/ work, as explained above -- you're 
simply pointing gcc at the right dirs.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman



Replies:
Re: Re: How does gcc find a library?
-- Mark Knecht
References:
How does gcc find a library?
-- Mark Knecht
Navigation:
Lists: gentoo-amd64: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
How does gcc find a library?
Next by thread:
Re: Re: How does gcc find a library?
Previous by date:
How does gcc find a library?
Next by date:
Re: Re: How does gcc find a library?


Updated Jun 17, 2009

Summary: Archive of the gentoo-amd64 mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.