I am trying to be able to compile and link code from within a code generator I am writing.
I can run the xHarbour compile step (ie .prg to .c) fine with:
FUNCTION CompilePRG( str_PRGName )
 LOCAL int_CompileReturn
 ? "Compiling " + str_PRGName + ".prg to " + str_PRGName + ".c"
 int_CompileReturn := ExecuteProcess( "./../../xharbour/bin/harbour " + str_PRGName + ".prg -n -I./../include -I./../../xharbour/include" )
 IF int_CompileReturn == 0
  int_CompileReturn := CompileC( str_PRGName )
 ENDIF
 RETURN int_CompileReturnBut the C compile (.c to .o) fails. I get return value of 1. When I read from @fh_StdOut I get:
gcc: `pkg-config: No such file or directory
gcc: gtk+-2.0`: No such file or directory
cc1: error: unrecognized command line option "-fcflags"
The function is:
FUNCTION CompileC( str_CName )
 RETURN ExecuteProcess( "gcc " + str_CName + ".c -c -I./../include -I./../../xharbour/include `pkg-config --cflags gtk+-2.0`" )I assume for some reason the pkg-config expansion isn't being properly recognised or can't start the process or something. Can you think of any possible work around. I could try using the RUN command but then I have to find a way to retrieve the exit code (for the solution to be ideal).
Here is my ExecuteProcess() function:
FUNCTION ExecuteProcess( str_Execute )
 LOCAL fh_ChildProcess
 LOCAL fh_StdIn
 LOCAL fh_StdOut
 LOCAL fh_StdErr
 LOCAL int_ReturnStatus
 LOCAL str_Buffer
 str_Buffer := Space(1024)
 ? "Starting Child Process"
 fh_ChildProcess := HB_OpenProcess( str_Execute, @fh_StdIn, @fh_StdOut, @fh_StdErr )
 ? "Returned Process Handle is:", fh_ChildProcess
 int_ReturnStatus := HB_ProcessValue( fh_ChildProcess )
 ? "Child Process returned status:", int_ReturnStatus
 FRead( fh_StdErr, @str_Buffer, 1024 )
 ? "str_Buffer"
 ? str_Buffer
Â
 FClose( fh_ChildProcess )
 FClose( fh_StdIn )
 FClose( fh_StdOut )
 FClose( fh_StdErr )
 ? "Handles closed"
 RETURN int_ReturnStatusThanks
Doug (xProgrammer)