Click to See Complete Forum and Search --> : PHP >> Mingw32-g++.exe


Rojay
10-01-2005, 11:31 AM
i have a script that takes c++ source code from an HTML textbox ( written by user )
and pass it to php and this php code writes the source code to a *.cpp file
and then usuing exec() i compile that .cpp
the problem is when i use exec() on any program it captures the output and put it in an array
exec("help.exe",$array);

and this array will hold the lines displayed
but when i use exec() on mingw32-g++ it doesnt store the output in the array no matter what i do
what are the limitations for exec or system to store the output ??
i made two programs to output string "hello world" using cout and printf and both work fine and the php stores the output "hello world"

can anyone help PLEASE

drew010
10-02-2005, 03:02 AM
well, when compiling an app with g++ isn't there supposed to be no output if the program compiled fine

Rojay
10-02-2005, 06:53 AM
yes
but if thers an error it should display each error on a different line

like this :

mingw32-g++ output: {ERROR GOES HERE}

but it doesnt ... it doesnt capture any output at all

Weedpacket
10-02-2005, 08:30 AM
Aren't error messages directed to stderr instead of stdout? Maybe tacking "2>1" on the end of the commandline to redirect stderr back to stdout would help?

drew010
10-02-2005, 02:20 PM
yeah weed is right, exec wont pick up whats sent to stdout since thats immediately flushed, and the compiler sends those errors to stderr.

Rojay
10-03-2005, 04:52 AM
but its not always error messages
its just any output either that compilation failed or compilation results
you guys know mingw32 ??

and can you elaborate the "2>1" part ?