0

Hi,
I want to compile a C/C++ file from php script and generate an error file in Windows 7. I am using MinGW32 as C compiler whose path is included in Environment variables (PATH='C:\MinGW32\bin') and WAMP 2.2. Tried using the below php scripts, error file is generated but it is empty ($ferr.err is 0kb).

     // Type 1
     echo `gcc -o $fexe $fsource 2> $ferr.err`;

     // Type 2
     $command = "gcc -o $fexe $fsource 2> $ferr.err";
     $result = shell_exec($command);

     // Type 3
     system("gcc -o $fexe $fsource 2> $ferr.err");   

What is the reason? How to solve this problem?

----
Thanks in advance..

Edited by amar007sv

2
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by pritaeas
0

pritaeas
Yes it is related to gcc.
dir > dirlist.txt works fine.

Edited by amar007sv

0

c_php

This is the screenshot of compiling my php file (e.g. hell.php). The php file contains the following code,

<?php
echo `gcc hell.c`;
?>

and my C file (hell.c) contains the below code.

int main()
{
    printf("Hello World
    return 0;
}

Now I want the error message to be passed into an error file such as hell.err.
I don't think there is any permission issue. I hope my query is clear to you now.

0

I mentioned it, because I thought you were on a *nix machine. Have you tried with filenames without the dollar sign?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.