开发者

Php script to compile c++ file and run the executable file with input file

开发者 https://www.devze.com 2023-03-29 19:59 出处:网络
I need a php script to compil开发者_如何学编程e 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 resul

I need a php script to compil开发者_如何学编程e 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 ?


Call a command-line C++ compiler using system, exec, or backticks. There is no C++ compiler written in PHP.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消