Problem with linking libraries using gcc
I'm doing a project for my CS2204 Unix class, and I'm having problems with the -L and -l options that go with gcc. I have this file structure set up in my home directory
p4
libsrc
myutil.c
src
makefile
myshell.c
include
myutil.h
There's a function in myutil.c called encrypt(). I call this function from main() which is in myshell.c. The function's prototype is in myutil.h.
The problem comes when I try to build the program. I cd to ~/p4/src/ and call make. In the makefile, it executes the command
gcc -I ../include -L ../libsrc -l util myshell.c -o myshell
The output I get from the command is this...
/tmp/cceOFU2Y.o(.text+0x18): In function `main':
: undefined reference to `encrypt'
collect2: ld returned 1 exit status
make: *** [all] Error 1
I'm positive that it is all syntactically correct. I've tested it in Visual Studios .NET 2003. I don't know why I can't get it to link. Oh, also, before I run make, I cd to ~/p4/libsrc/ and run these two commands
gcc -c myutil.c
ar rv libutil.a myutil.o
in order to build the library. Please help.
|