I have a file hello.c
#include<stdio.h>
void hello()
{
printf("Hello!\n");
}
A header hello.h
#ifndef _hello_
#define _hello_
void hello();
#endif
main.c
#include<stdio.h>
#include "hello.h"
int main()
{
hello();
return 0;
}
I am currently in the folder /home/user/name/programs
I am trying to build a static library mylib.a. Here is what I do to build it
1. gcc -c hello.c
2. ar rcs mylib.a hello.o
3. gcc -static main.c -L/home/user/name.programs -lib -o hello
I get the following error
/usr/bin/ld: cannot find -lib
collect2: ld returned 1 exit status
My questions are
`1. why is gcc searching for the file in the folder /usr/bin - I understand this is
what is happening ?
2. How do I fix this?`