When I compile a C/C++ program with popen
in PHP, I get this error:
g++: error trying to exec 'cc1plus': execvp: No such file or directory
But if I run PHP code in the shell, it works fine.
In Arch Linux.
PHP code:
<?php
function rfile($fp) {
$out="";
while (!feof($fp)) {
$out.= fgets($fp, 1024000);
}
return $out;
}
$p = popen('g++ -Wall -g aplusb.cc -o aplusb 2>&1', 'r');
$result = rfile($p);
pclose($p);
echo $result;
?>
You need to install the gcc-c++
package.
yum install gcc-c++