- Playing with a way to build library objects without immediately linking
- I am then also seeing how to link it to an application which `_start_` can find its `main` symbol
This commit is contained in:
Tristan B. Velloza Kildaire 2024-02-25 19:08:19 +02:00
parent 86c7e49cc2
commit 9c72115dc1
3 changed files with 22 additions and 0 deletions

9
scratch/Makefile Normal file
View File

@ -0,0 +1,9 @@
library:
gcc library.c -shared -o library.o
clean:
rm library.o
rm main
main:
gcc main.c library.o -o main

4
scratch/library.c Normal file
View File

@ -0,0 +1,4 @@
int myFunc(int x)
{
return x*2;
}

9
scratch/main.c Normal file
View File

@ -0,0 +1,9 @@
extern int myFunc(int);
#include<stdio.h>
int main()
{
int result = myFunc(4);
printf("myFunc(4): %d\n", result);
}