On Thu, Jan 10, 2002 at 02:36:05PM +0100, Johan Andersson wrote:
> > control.o: \
> > compile control.c readwrite.h open.h getln.h stralloc.h gen_alloc.h \
> > substdio.h error.h control.h alloc.h scan.h
> >         ./compile $(LDAPFLAGS) $(LDAPLIBS) $(LDAPINCLUDES) control.c
> 
> I have no problem with making the target "control.o". 
> I had already made that change to my Makefile to you see.. :)
> 
> My line looks like this when I "make qmail-qmtpd":
> ./compile -DQLDAP_CLUSTER -DDASH_EXT  -DUSE_CONTROLDB -DQLDAP_BAILOUT -DUSE_RFC2307 
>-DUSE_RFC822 -L/usr/local/lib -L/usr/local/openldap/lib -L/usr/local/ssl/lib -lldap 
>-llber -I/usr/local/include -I/usr/local/openldap/include control.c
> 
> But when I try to make qmail-qmtpd (or try to make a target that uses control.o) it
> failes with the error message "undefined reference to..." in the function 
>control_ldap_search.
> And all the functions that are undefined is declared in my ldap.h (in 
>openldap_dir/include).
> It seems like it can't find the header file.. but it is included at the top of 
>control.c, and I got
> no errors about including that file.. Very strange!
> 
> I think that the weirdest thing is that I can make the control.o target, without any 
>errors,
> but when I try to use control.o.. I get errors.
> 
This is absolutly normal. You are using the qmail-ldap-control patch which
adds ldap function to control.c. So control.o needs the shared ldap
libraries to link without problems. In other words, when a program that
uses control.o is linked together you need to add $(LDAPLIBS) to the
./load command or cc will not find the needed ldap functions.

Normaly a program is compiled in two stages. First the Code is compiled
which gives the *.o files. When all needed *.o files are compiled the
linker builds with those *.o files and the specified libraries (all the
-llib flags) the applications. Now if a library or a *.o file is missing
the program can not be built because the functions programmmed in this c
file or library can not be found so the linker (ld) produces the error:
<file where the unkown function is used>: undefined reference to <function>

djb is using ./compile and ./load as wrappers to the compiler (cc) and the
linker/loader (ld or cc). So as said befor you need to add $(LDAPLIBS) to
all those ./load lines where control.o is used.

And befor you try to start qmail-ldap after a successful make setup check
read the section about shared libraries of
http://www.lifewithqmail.org/ldap

A side note: it is not needed to add $(LDAPLIBS) to ./compile calls or
$(LDAPINCUDES) to ./load calls. While compiling (cc -c / ./compile) no
libraries are necessary and in the linking pahse (ld / ./load) no include
files are needed.

-- 
:wq Claudio

tail -23 QLDAPINSTALL

Reply via email to