Mark Knecht <[email protected]> posted
[email protected], 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:
> 
> m...@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:
> 
> m...@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


Reply via email to