fushar / regrader

ICPC-style programming contest system
MIT License
34 stars 25 forks source link

Set the compile command #73

Open ecojuntak opened 8 years ago

ecojuntak commented 8 years ago

I have finished to install the grader, but I still confused to set the compile command. I don't know what this part mean /usr/bin/g++ -o [PATH]/source [PATH]/source.cpp -O2 -s -static -lm and this part [PATH]/source

fushar commented 8 years ago

Hi -- basically you just need to replace the /usr/bin/g++ part to your compiler path. Usually you don't need to do this if you're using Ubuntu and you have installed g++, as it will be installed there by default.

ecojuntak commented 8 years ago

I have replace the usr/bin/g++ part, but it still not work. I found this error message on the terminal when i try to submit the answer A PHP Error was encountered Severity: WarningMessage: exec(): Unable to fork [-o secret-68a550951829942d1acd6c2a35519343/7/source/source secret-68a550951829942d1acd6c2a35519343/7/source/source.cpp -O2 -s -static -lm 2>&1]Filename: /var/www/html/grader/application/controllers/Grader.phpLine Number: 169 Are you have solution for this error?

fushar commented 8 years ago

Replace with what? Seems like you're missing it? (Unable to fork [-o ...)

ecojuntak commented 8 years ago

I just delete the /usr/bin/g++ ..

fushar commented 8 years ago

Hmm why? I said replace with your actual compiler path, if necessary

ecojuntak commented 8 years ago

I have locate some path on my PC. /usr/bin/g++ /usr/bin/g++-4.8 /usr/bin/g++-5 /usr/bin/i686-w64-mingw32-g++ /usr/bin/x86_64-linux-gnu-g++ /usr/bin/x86_64-linux-gnu-g++-4.8 /usr/bin/x86_64-linux-gnu-g++-5 /usr/bin/x86_64-w64-mingw32-g++ I have used /usr/bin/g++ but it still can't work.

fushar commented 8 years ago

What error did you get when you used /usr/bin/g++?

ecojuntak commented 8 years ago

A PHP Error was encountered Severity: WarningMessage: exec(): Unable to fork [/usr/bin/g++ -o secret-68a550951829942d1acd6c2a35519343/13/source/source secret-68a550951829942d1acd6c2a35519343/13/source/source.cpp -O2 -s -static -lm 2>&1]Filename: /var/www/html/grader/application/controllers/Grader.phpLine Number: 169

fushar commented 8 years ago

Hmm strange. Could you try running a very simple PHP file that just contains something like

<?php echo exec('/usr/bin/g++'); ?>

just to test whether your PHP settings is good?

ecojuntak commented 8 years ago

it show nothing

fushar commented 8 years ago

Good. Then try putting some C++ file inside the folder secret-68a550951829942d1acd6c2a35519343 (e.g. test.cpp), and then try compiling that file using the same exec() command, e.g

<?php echo exec('/usr/bin/g++ -o /full/path/to/secret-68a550951829942d1acd6c2a35519343/test /full/path/to/secret-68a550951829942d1acd6c2a35519343/test.cpp'); ?>

use full path for the secret folder

ecojuntak commented 8 years ago

It show nothing too