I am trying to compile a a c++ file on the server. I have a Windows 7 64 bit install along with mingw32 c/c++ compiler installed on the system running WampServer2.0 (php 5.3.0). I have already set the env variables to relative paths (c:\MinGW\bin). The following piece of code does not produce any executable in the Dest_folder, however the command runs perfectly well when executed from cmd (command prompt) and generates the executable
<?php
$string = system("g++ -o C:\\wamp\\www\\Dest_folder\\file.exe C:\\wamp\\www\\Dest_folder\\file.cpp", $retval);
echo $retval;
echo $string;
?>
The $string variable should returns the last line of the command output on success, and FALSE on failure (which in this case does not return anything) and the $retval variable returns 1. Am I doing anything wrong? Also I noticed, every successful system() call (all other calls except for g++ compilation) produces 0 as $retval.