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 )
Code: Select all
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_CompileReturn
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:
Code: Select all
FUNCTION CompileC( str_CName )
RETURN ExecuteProcess( "gcc " + str_CName + ".c -c -I./../include -I./../../xharbour/include `pkg-config --cflags gtk+-2.0`" )
Here is my ExecuteProcess() function:
Code: Select all
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_ReturnStatus
Doug (xProgrammer)