Gentoo Archives: gentoo-amd64

From: Mark Knecht <markknecht@×××××.com>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] Re: How does gcc find a library?
Date: Sun, 17 May 2009 20:36:19
Message-Id: 5bdc1c8b0905171336g1442310fh5d807274bc2d1b06@mail.gmail.com
In Reply to: [gentoo-amd64] Re: How does gcc find a library? by Duncan <1i5t5.duncan@cox.net>
1 On Sun, May 17, 2009 at 1:13 PM, Duncan <1i5t5.duncan@×××.net> wrote:
2 > Mark Knecht <markknecht@×××××.com> posted
3 > 5bdc1c8b0905170849j3e0198ebrf29bc2042dda7ee4@××××××××××.com, excerpted
4 > below, on  Sun, 17 May 2009 08:49:13 -0700:
5 >
6 >> Hi,
7 >>    I'm trying to compile a new piece of software for MythTV hardware
8 >> support that's not in portage. I'm not a programmer so I'm woefully
9 >> uneducated in this area but how does gcc find a library that a piece of
10 >> code is requiring?
11 >
12 > Well, I'm not a programmer either, but I think I understand a bit about
13 > this just from troubleshooting various ebuilds over time.  YMMV, but the
14 > below is what I'd try.
15 >
16 > gcc looks in various standard system locations (/usr/include, among
17 > others) automatically for the header files, which tell it the interfaces
18 > the library supplies.  The interfaces consist of the the functions, etc,
19 > along with the parameters they take, their orders and their types (int,
20 > string pointer, whatever).
21 >
22 > For header files not found in the standard locations and not in the
23 > working dir that's being compiled, gcc has the -I<includedir> parameter,
24 > among others.
25 >
26 > Then for linking, there's  -L<linkdir>, if you find you need it later.
27 >
28 >>    My code setup is this:
29 >>
30 >> /home/mark/scte65scan-0.2
31 >> /home/mark/scte65scan-0.2/libhdhomerun
32 >
33 >> The code all exists in the scte65scan directory. The required library is
34 >> in libhdhomerun.
35 >>
36 >>    When I attempt to build the code I get the error message:
37 >>
38 >> mark@Sector9 ~/scte65scan-0.2 $ make -f Makefile.hdhr cc -O2 -DHDHR -c
39 >> tunerdmx.c -o tunerdmx.o tunerdmx.c:39:23: error: hdhomerun.h: No such
40 >> file or directory
41 >
42 >>    So it seems it cannot find the library because hdhomerun.h is in
43 >> the libhdhomerun diectory:
44 >
45 >>    The tunerdmx.c program has an include for hdhomerun:
46 >>
47 >> #ifdef HDHR
48 >> #include "hdhomerun.h"
49 >>
50 >> which is what I guess is kicking off the problem. The makefile looks
51 >> like this:
52 >>
53 >> mark@Sector9 ~/scte65scan-0.2 $ cat Makefile.hdhr
54 >> HDHR_DIR=./libhdhomerun
55 >
56 > That part looks right, since it's a subdir, and the (snipped) LIBOBJS
57 > point into it as expected.
58 >
59 >> CFLAGS += -O2 -DHDHR
60 >> LDFLAGS += -lpthread
61 >
62 >>    So, how do I tell gcc that the library is here so it can build it?
63 >
64 > Add to that CFLAGS line: -I./libhdhomerun .  See if that helps.  You can
65 > try the absolute form too (/home/mark...) but that can cause problems if
66 > things are moved around, later.  The relative form should help avoid
67 > those problems.
68 >
69 > If you later get hungup in linking, there's the -L<dir> parameter for
70 > that, too, but I'd not add it until it looks like it's needing it.
71 >
72 > As I said above, this is troubleshooting level knowledge.  Try it and see
73 > if it works more than really understanding the full implications, tho I
74 > believe I understand why it /should/ work, as explained above -- you're
75 > simply pointing gcc at the right dirs.
76 >
77 > --
78 > Duncan - List replies preferred.   No HTML msgs.
79 > "Every nonfree program has a lord, a master --
80 > and if you use the program, he is your master."  Richard Stallman
81 >
82
83 Thanks Duncan,
84 I think it's turning out that this code has not actually been
85 debugged and the errors are really in the program's code itself. I've
86 managed to get a few of the simple typo's debugged but there are still
87 some problems that the developer is going to have to deal with as they
88 are way beyond me.
89
90 I found that the inclusion of the libhdhomerun stuff could be
91 accomplished in the makefile by changing the CFLAGS line to include
92 it::
93
94 CFLAGS += -I libhdhomerun -O2 -DHDHR
95
96 This still leaves me with a few problems so it's now a matter of
97 waiting on the developer.
98
99 Thanks again,
100 Mark

Replies

Subject Author
[gentoo-amd64] Re: How does gcc find a library? Duncan <1i5t5.duncan@×××.net>