I have a simple program with 2 files:
test.c:
#include "head.h"int main(){ print(); return 0;}
func.c:
#include "head.h"void print(void){ printf("hello, world!\n");}
and the head file "head.h":
#include <sys/socket.h>#include <stdio.h>void print(void);
I would like to use ld to link the compiled .o files, so:
compile: gcc -c -m64 *.clinkelf: ld -m elf_x86_64 -o a.out *.o -lc
However, the ld command report a warning of no _start, and the output file cannot run.
If I change the "main" function to "_start", it doesn't report but still cannot run.
I've searched across internet, and cannot find a way to use ld to link the file.
I also use -v to output gcc command, and using it as the option of ld, but reporting error of not finding temp files.
I only need to create a executable file and a dynamic library. Would there be an easy way of doing that?