u/quipsticklein r/C_Programming • Recommends
Why can't the linker find main?
I have a very simple C program
int main() {
return 0;
}
It compiles fine with GCC, but if I use the -c option and then the linker `ld`, it segfaults.
> gcc -c hmm.c
> ld -o hmm hmm.o --entry main
> ./hmm
segmentation fault
I stumbled across this problem following this neat video. which works up until 20:30 and narrowed down the issue to, I think, trying to specify the entry point for the linker.
I'm using `gcc 14.2.1` and `ld 2.43.1`