From 513fb920ce367afae5d6cbe8155837d1ece84b75 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 25 Feb 2024 19:17:15 +0200 Subject: [PATCH] Makefile - Added `-c` to ONLY compile but do NOT attempt to link and make an executable. If we try this it looks for a `main` symbol to satisfy the `_start` for linux-ld - Updated the build instructions for being able to statically link against the library --- scratch/Makefile | 4 ++-- scratch/library.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scratch/Makefile b/scratch/Makefile index b184f993..6ccef176 100644 --- a/scratch/Makefile +++ b/scratch/Makefile @@ -1,9 +1,9 @@ library: - gcc library.c -shared -o library.o + gcc -c library.c -o library.o clean: rm library.o rm main main: - gcc main.c library.o -o main + gcc main.c library.o -o main diff --git a/scratch/library.c b/scratch/library.c index 2ca8a565..6e8c8aae 100644 --- a/scratch/library.c +++ b/scratch/library.c @@ -1,4 +1,4 @@ int myFunc(int x) { - return x*2; + return x*4; }