c - linker can't find libraries -
i can't link program "set-manipulation" libraries needs.
here 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 target 'set-manipulation' failed make: *** [set-manipulation] error 1
here content of -l/home/jenia/learn-c-the-hard-way/lib
:
/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 set_theory.so -- 11
here makefile give error (the makefile of set-manipulation program):
prefix?=/home/jenia/learn-c-the-hard-way cflags=-g -wall -i${prefix}/lib/include ldflags=-l${prefix}/lib install_dir=${prefix}/apps all: set-manipulation set-manipulation: main.o gcc $(ldflags) -lset_theory $(cflags) -o "$@" main.o install: install -d $(install_dir)/set-manipulation install set-manipulation $(install_dir)/set-manipulation clean: rm -f *.o rm -f set-manipulation rm -rf *.dsym
can please tell me how link program it's library?
-l../../patch_to_library.a/set_theory.a
the library must named libname.a/.so
example : g++ set.cpp -l../../libset_theory.a -lset_theory
if don't have named library libname.a dont't link lib.
libtest.a
an corect link syntax :
g++ (link) -ltest
you see ? -l test don't include lib. l - lib
g++ -g -wall -l/lib_dir/xx foo.o test.o -lset_theory -o test
name of lib must libset_theory.a
Comments
Post a Comment