B
bashcommando
Guest
I used gcc on my code and it turned it into a object file. I have no idea why, but how do I make it into a elf program?
gcc ./main.cpp -o myprogram
By default, if you do not use the -o option to name the executable, gcc will create an executable file called a.out, regardless of the name of the .c file. I always use the -o option.I used gcc on my code and it turned it into a object file. I have no idea why, but how do I make it into a elf program?
gcc -Wall -Wextra -o foo foo.c bar.c
By default, if you do not use the -o option to name the executable, gcc will create an executable file called a.out, regardless of the name of the .c file. I always use the -o option.
For beginners, I recommend the following command line to compile one or more files:
Code:gcc -Wall -Wextra -o foo foo.c bar.c
See: GCC Options for more information.
gcc main.o foo.o bar.o -o programname
MYFILEPATH = ./src/
CC = gcc
CFLAGS = -Wall -Wextra -O2
OBJECTS = main.o foo.o bar.o
programname: $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o programname
main.o: $(MYFILEPATH)main.c
$(CC) $(CFLAGS) -c $(MYFILEPATH)main.c
foo.o: $(MYFILEPATH)foo.c
$(CC) $(CFLAGS) -c $(MYFILEPATH)foo.c
bar.o: $(MYFILEPATH)bar.c
$(CC) $(CFLAGS) -c $(MYFILEPATH)bar.c
clean:
rm ./programname ./*.o