When I use the terminal to compile the c file it was normal but through the php to do that will get the error message:
Code: Select all
"gcc: error trying to exec 'cc1': execvp: No such file or directory"
Code: Select all
My OS: CentOS Linux release 7.6.1810 (Core)
Code: Select all
gcc --version:
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Code: Select all
which gcc :
/usr/bin/gcc
Code: Select all
PATH=/usr/bin:$PATH
I simply take a code that someone says they can work, but that still failed for me. Below is the code I found.
Code: Select all
<?php
$data = '#include<stdio.h>
int main(){
printf("Hello World");
return 0;
}
';
$my_file = 'code.c';
file_put_contents($my_file, $data);
system("gcc {$my_file} &> error.txt");
$error = file_get_contents("error.txt");
if($error=='')
system("./a.out");
else
echo $error;
?>
And I try to reinstall the gcc and g++ for many times, but the error remains...
Hope somebody can know why to have this problem.