Skip to content
How to compile and run C program imported from GitHub
Profile icon
moderndaymage

Hi, I've just imported my own C program from my GitHub repo, when I try to press the Run button, it asks me to configure run from repl.it files. What should I do for it to compile and run?

You are viewing a single comment. View All
Answered by MocaCDeveloper [earned 5 cycles]
View Answer
Profile icon
MocaCDeveloper

I always use the gcc compiler, so I'd personally create a makefile:

SRC = $(wildcard *.c) # if there is a source path, put that before the '*' and make sure to end with / HDR = $(wildcard *.h) # same for this one COMPILE = gcc -Warn -o main.o main.c # -Warn shows warning .PHONY: create .PHONY: clean create: ${SRC} ${HDR} ${COMPILE} ${SRC} ${HDR} # this does 'gcc -Warn -o main.o main.c' then all of the SRC(.c) files and HDR(.h) files clean: # cleaning all output files for the project rm *.o

Then, within the .replit file, put:

language='c' run='make create && ./main.o'

To me personally this is the easiest way to fully compile the project. I always use gcc and makefiles to compile my projects

Profile icon
MocaCDeveloper

@moderndaymage
Yes that is the normal error I always get as well! Copy the source code from a makefile I previously made and you'd be set.
Here is the link: https://github.com/ARACADERISE/Jang/blob/master/Makefile

in this Makefile, I put src/*.c and src/*.h, you can adjust the file to fit your project.

Also, that error is still very confusing to me. I don't understand why the makefile doesn't compile, so just copy and paste the makefile I linked above to your Makefile and adjust the file to fit your needs

Also be aware that the Makefile I linked above has a few other ideals to it such like Memory checking with valgrind.

Ping me if you have any more questions or need help!

Profile icon
moderndaymage

@targetfanttthat
I've tried copy pasting your makefile but it gives me this when I try to run the program:

makefile:9: *** mising operator. Stop.

Profile icon
moderndaymage

@targetfanttthat
Hi, sorry for the late reply, I've copied your makefile and it finally worked. Thanks, you're a lifesaver.

Profile icon
MocaCDeveloper

@moderndaymage
Anytime! And don't be sorry I don't expect responses back right away. Just ping me if you ever need help!