Recently I've been learning linker and trying to link simple files using ld, but then, I failed to do so (probably because of architecture x64?... I cannot really tell). Here are the files I used:
#include<stdio.h>
int fun(int x);
int main(){
int i = fun(10);
printf("%d\n",i);
return 0;
}
and:
int fun(int x){
return x+10;
}
I compiled them with gcc -c commands and then linked them into a single file with command:
ld -r -o a.o main.o fun.o
and, finally, I wanted to make the a.o file into an executable. I have read /usr/lib/ctr0.o is needed, but not having found it, I tried /x86_64-linux-gnu/crt1.o (and learned it did not work). What is a replacement for crt0.o then? I do not have crt0.o in my system (I did my search, but probably not where I should have). What other file can I use in its place, so that the command:
ld a.o <SOME_FILE> -lc
is going to produce executable output?