I have these 3 files under /Users/koraytugay
checksum.h
enc.h
libsec.a
libsec.a is an archive file existing of checksum.o and enc.o
Korays-MacBook-Pro:~ koraytugay$ nm libsec.a
libsec.a(enc.o):
0000000000000090 s EH_frame0
0000000000000000 T _enc
00000000000000a8 S _enc.eh
U _strlen
libsec.a(checksum.o):
0000000000000078 s EH_frame0
0000000000000000 T _checkSumFor
0000000000000090 S _checkSumFor.eh
Korays-MacBook-Pro:~ koraytugay
This is how I try to compile my hello.c file:
Korays-MacBook-Pro:HelloWorld koraytugay$ gcc hello.c -L/Users/koraytugay -libsec -o koko.out
hello.c:4:10: fatal error: 'enc.h' file not found
#include <enc.h>
^
1 error generated.
What am I doing wrong?
Btw, hello.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <enc.h>
#include <checksum.h>
// code here..
In addition to the lack of -I.
switch to bring the current directory into the include path, the link specification should read -lsec
, not -libsec
. The linker takes the string after the -l
switch, prepends lib
, and looks for that. In other words, -lfoo
implies that there should be a libfoo.a
(static) or libfoo.so
(shared) file on the link path (which itself is specified with the -L
switch).