linker can't find libraries

Sun Nov 1 19:36:00 GMT 2015

I can't link my program "set-manipulation" with the libraries it needs.

Here is the message: 

    gcc -L/home/jenia/learn-c-the-hard-way/lib -lset_theory -g -Wall -I/home/jenia/learn-c-the-hard-way/lib/include -o "set-manipulation" main.o
    /usr/bin/ld: cannot find -lset_theory
    collect2: error: ld returned 1 exit status
    Makefile:9: recipe for target 'set-manipulation' failed
    make: *** [set-manipulation] Error 1

Here is the content of `-L/home/jenia/learn-c-the-hard-way/lib`: 

      total used in directory 29 available 216513716
      drwxr-xr-x  3 jenia jenia 4096 Nov  1 12:47 .
      drwxr-xr-x  8 jenia jenia 4096 Oct 31 11:44 ..
      drwxr-xr-x  2 jenia jenia 4096 Nov  1 12:47 include
      -rwxr-xr-x  1 jenia jenia 6804 Nov  1 12:47 set_theory.a -- 50
      -rwxr-xr-x  1 jenia jenia 9664 Nov  1 12:47 -- 11

Here is the makefile which give the error (the makefile of set-manipulation program):

    CFLAGS=-g -Wall -I${PREFIX}/lib/include
    all: set-manipulation
    set-manipulation: main.o
    	gcc $(LDFLAGS) -lset_theory $(CFLAGS) -o "$@" main.o

    install: all
    	install -d $(INSTALL_DIR)/set-manipulation
    	install set-manipulation $(INSTALL_DIR)/set-manipulation
    	rm -f *.o
    	rm -f set-manipulation
    	rm -rf *.dSYM

Can someone please tell me how to link my program with it's library?


More information about the Gcc-help mailing list