【发布时间】:2012-01-05 23:48:39
【问题描述】:
我在 Windows 机器上使用 PHP。我也使用 Dev C++。我可以使用以下命令在 CMD 上完美编译 .cpp 文件:
g++ hello.cpp -O3 -o hello.exe
现在我要做的是使用 php system() 函数运行相同的命令,所以它看起来像这样:
system("g++ c:\wamp\www\grader\hello.cpp -O3 -o C:\wamp\www\grader\hello.exe");
但它不会编译。我迷路了,请告诉我我错过了什么?
我也查看了这个问题,这正是我所需要的,但我在那里找不到适合我的案例的有用解决方案:
Php script to compile c++ file and run the executable file with input file
【问题讨论】:
-
您确定
g++已安装并在您的Windows 服务器上的PATH 中可见吗? -
另外,你确定运行PHP的账号对
c:\wamp\www\grader目录有修改权限吗?