I need a php script to compile C/C++ file. After compiling and getting the executable of that file i need to run that file with a argument of input.txt file and then compare the result with output.txt file
How can i do this ?
Is PHP required? If not consider GNU Make. It was especially developed to solve such problems as your. With this simple Makefile
:
OUT = app
CFLAGS = -O2 -Wall
$(OUT): main.o
clean:
rm -rf $(OUT) main.o
You get ability to easy compile your program with different compiler flags and performing clean operations:
make # for compiling
make clean # for remove binaries
Make
has a good manual. Also, there is similar tool from Microsoft called nmake.