douzhun4124 2015-12-21 16:13
浏览 52

无法通过PHP ubuntu服务器编译C文件

I really read every answer in this website, but I could not solve my problem.

I want to compile C file via gcc, and after various tests, I didn't get nothing.

Here's my php code:

    $filename = "file.c";
        $pathfile = exec("readlink -f " . $filename);
        $path = str_replace($filename, '', $pathfile);
        exec("gcc-4.8 ".$pathfile." -o ".$path."runner.out 2>&1",$output,$status);

        print_r($output);
        print_r($status);

This is the actual command that php executes:

gcc-4.8 /home/vagrant/sites/test/codetest/file.c -o /home/vagrant/sites/test/codetest/runner.out 2>&1

If I try to execute this line on terminal it works.

And this is the output if I try it via php:

Array ( [0] => gcc-4.8: error trying to exec 'cc1': execvp: No such file or directory ) 1

I can't figure out what's the problem, I also changed the permission of the codetest folder, and the permission to the gcc-4.8 to 777, it still not working.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法