Gentoo Archives: gentoo-amd64

From: Mark Knecht <markknecht@×××××.com>
To: gentoo-amd64@l.g.o
Subject: [gentoo-amd64] How does gcc find a library?
Date: Sun, 17 May 2009 15:49:20
Message-Id: 5bdc1c8b0905170849j3e0198ebrf29bc2042dda7ee4@mail.gmail.com
1 Hi,
2 I'm trying to compile a new piece of software for MythTV hardware
3 support that's not in portage. I'm not a programmer so I'm woefully
4 uneducated in this area but how does gcc find a library that a piece
5 of code is requiring?
6
7 My code setup is this:
8
9 /home/mark/scte65scan-0.2
10 /home/mark/scte65scan-0.2/libhdhomerun
11
12 The code all exists in the scte65scan directory. The required library
13 is in libhdhomerun.
14
15 When I attempt to build the code I get the error message:
16
17 mark@Sector9 ~/scte65scan-0.2 $ make -f Makefile.hdhr
18 cc -O2 -DHDHR -c tunerdmx.c -o tunerdmx.o
19 tunerdmx.c:39:23: error: hdhomerun.h: No such file or directory
20 tunerdmx.c: In function ‘open_hdhr’:
21 tunerdmx.c:49: warning: assignment makes pointer from integer without a cast
22 tunerdmx.c:51: error: ‘id_str’ undeclared (first use in this function)
23 tunerdmx.c:51: error: (Each undeclared identifier is reported only once
24 tunerdmx.c:51: error: for each function it appears in.)
25 tunerdmx.c:54: error: ‘uint32_t’ undeclared (first use in this function)
26 tunerdmx.c:54: error: expected ‘;’ before ‘device_id_requested’
27 tunerdmx.c:55: error: ‘device_id_requested’ undeclared (first use in
28 this function)
29 tunerdmx.c:58: warning: initialization makes pointer from integer without a cast
30 tunerdmx.c: In function ‘demux_start’:
31 tunerdmx.c:172: error: ‘ret_error’ undeclared (first use in this function)
32 tunerdmx.c: In function ‘demux_read’:
33 tunerdmx.c:245: error: ‘uint8_t’ undeclared (first use in this function)
34 tunerdmx.c:245: error: ‘pbuf’ undeclared (first use in this function)
35 tunerdmx.c:245: error: ‘VIDEO_DATA_BUFFER_SIZE_1S’ undeclared (first
36 use in this function)
37 tunerdmx.c: In function ‘tuner_tune’:
38 tunerdmx.c:382: error: ‘ret_error’ undeclared (first use in this function)
39 tunerdmx.c: In function ‘tuner_checklock’:
40 tunerdmx.c:414: error: ‘arg’ undeclared (first use in this function)
41 tunerdmx.c:414: error: ‘tp’ undeclared (first use in this function)
42 tunerdmx.c:415: error: ‘ret_error’ undeclared (first use in this function)
43 tunerdmx.c:425: warning: passing argument 2 of ‘__rawmemchr’ makes
44 integer from pointer without a cast
45 tunerdmx.c:425: warning: passing argument 2 of ‘__builtin_strchr’
46 makes integer from pointer without a cast
47 make: *** [tunerdmx.o] Error 1
48 mark@Sector9 ~/scte65scan-0.2 $
49
50 So it seems it cannot find the library because hdhomerun.h is in
51 the libhdhomerun diectory:
52
53 mark@Sector9 ~/scte65scan-0.2 $ ls libhdhomerun
54 Makefile hdhomerun_config.c hdhomerun_discover.c
55 hdhomerun_types.h
56 README hdhomerun_control.c hdhomerun_discover.h
57 hdhomerun_video.c
58 hdhomerun.h hdhomerun_control.h hdhomerun_os.h
59 hdhomerun_video.h
60 hdhomerun_channels.c hdhomerun_debug.c hdhomerun_os_posix.h lgpl.txt
61 hdhomerun_channels.h hdhomerun_debug.h hdhomerun_os_windows.h
62 hdhomerun_channelscan.c hdhomerun_device.c hdhomerun_pkt.c
63 hdhomerun_channelscan.h hdhomerun_device.h hdhomerun_pkt.h
64 mark@Sector9 ~/scte65scan-0.2 $
65
66 The tunerdmx.c program has an include for hdhomerun:
67
68 #ifdef HDHR
69 #include "hdhomerun.h"
70
71 which is what I guess is kicking off the problem. The makefile looks like this:
72
73 mark@Sector9 ~/scte65scan-0.2 $ cat Makefile.hdhr
74 HDHR_DIR=./libhdhomerun
75
76 LIBOBJS += $(HDHR_DIR)/hdhomerun_pkt.o
77 LIBOBJS += $(HDHR_DIR)/hdhomerun_debug.o
78 LIBOBJS += $(HDHR_DIR)/hdhomerun_discover.o
79 LIBOBJS += $(HDHR_DIR)/hdhomerun_channels.o
80 LIBOBJS += $(HDHR_DIR)/hdhomerun_channelscan.o
81 LIBOBJS += $(HDHR_DIR)/hdhomerun_control.o
82 LIBOBJS += $(HDHR_DIR)/hdhomerun_video.o
83 LIBOBJS += $(HDHR_DIR)/hdhomerun_device.o
84
85 OBJS = scte65scan.o tunerdmx.o
86
87 CFLAGS += -O2 -DHDHR
88 LDFLAGS += -lpthread
89
90 ifeq ($(OS),Windows_NT)
91 BINEXT := .exe
92 LDFLAGS += -liphlpapi
93 else
94 ifneq ($(findstring solaris,$(shell echo $$OSTYPE)),)
95 LDFLAGS += -lns -lsocket
96 endif
97 ifneq ($(findstring darwin,$(shell echo $$OSTYPE)),)
98 CFLAGS += -arch i386 -arch ppc
99 endif
100 endif
101
102
103 all: scte65scan$(BINEXT)
104
105 $(LIBOBJS): %.o : %.c
106 $(CC) $(CFLAGS) -c $< -o $@
107
108 $(OBJS): %.o : %.c
109 $(CC) $(CFLAGS) -c $< -o $@
110
111 scte65scan$(BINEXT): $(OBJS) $(LIBOBJS)
112 $(CC) $(CFLAGS) $+ $(LDFLAGS) -o $@
113
114 clean:
115 rm -f scte65scan $(LIBOBJS) $(OBJS)
116 mark@Sector9 ~/scte65scan-0.2 $
117
118 So, how do I tell gcc that the library is here so it can build it?
119
120 Thanks,
121 Mark

Replies

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