[chord] How to use chord as a library ?

Emil Sit sit at MIT.EDU
Fri May 6 06:59:30 EDT 2005


On Fri, 06 May 2005 at 12:09 (+0800), ?????? wrote:
> test_dht : $(OBJS)
>         $(CC) -o test_dht $(CFLAGS) $(OBJS) -L/usr/local/lib -lsfs -L/usr/local/lib/sfs -lasync -lsvc -larpc -lsfscrypt -lsfsmisc -L/home/wuyj/sfsnet/dhash -ldhashclient -dhash -L/home/wuyj/sfsnet/utils -lutil -L/home/wuyj/sfsnet/merkle -lmerkle -L/home/wuyj/sfsnet/dhc -ldhc -L/home/wuyj/sfsnet/sfsrodb -lsfsrodb -L/usr/lib -lgmp

You must specify libraries to be linked in order from the most specific 
to the least specific, e.g. 

    $(OBJS)
    -ldhashclient 
    -lutil
    ../svc/.libs/libsvc.a
    -lsfsmisc
    -lsvc
    -lsfscrypt
    -larpc
    -lasync
    -lgmp

(Does your application need to link with libdhash?  Or just libdhashclient?)

This is a property of the way the linker resolves symbols in
libraries.  From ld(1)'s discussion of -l:

    The  linker will search an archive only once, at the location where
    it is specified on the command line.  If the archive defines a sym-
    bol  which  was  undefined in some object which appeared before the
    archive on the command line, the linker will include the  appropri-
    ate  file(s)  from the archive.  However, an undefined symbol in an
    object appearing later on the  command  line  will  not  cause  the
    linker to search the archive again.

-- 
Emil Sit / MIT CSAIL PDOS / http://pdos.csail.mit.edu/chord/  



More information about the chord mailing list