You are only catching the return code of the program, which is normally an integer where 0 means 'success' and anything else is an error code.
If you want to catch the actual output of the program (i.e. STDOUT and/or STDERR) You need to do one of these things:
- Use output buffering to capture the output of
system():
$command = "c:\\Dev-Cpp\\bin\\g++.exe c:\\wamp\\www\\hello.cpp -O3 -o c:\\wamp\\www\\hello.exe";
ob_start();
system($command, $returnCode);
$output = ob_get_clean();
exec($command, $output, $returnCode);
// ...or...
$output = shell_exec($command);
// ...or...
$output = `$command`;
If you want to catch the output of STDERR (which I suspect you do), you may need to add 2>&1 to the end of your command string.
Alternatively, you may want to look at proc_open(), which is more complicated but can give you finer-grained control over the child process and how it executes/passes data back to you.