I have a project on Lazarus that I want to compile a source using gcc, for this I have a TOpenDialog
called OpenDialog1
and a TProcess
called AProcess
.
I call gcc with this code:
procedure TFormMain.btCompileClick(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
AProcess := TProcess.Create(nil);
try
AProcess.CommandLine := 'gcc.exe ' + OpenDialog1.FileName;
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
AProcess.Execute;
OutputMemo.Lines.BeginUpdate;
OutputMemo.Lines.Clear;
OutputMemo.Lines.LoadFromStream(AProcess.Output);
OutputMemo.Lines.EndUpdate;
finally
AProcess.Free;
end;
end;
end;
It compiles ok(the project on Lazzarus), but when I was testing it, by trying to compile the source test.c, that is located at C:\Documents and Settings\Nathan Campos\Desktop
, I got this on OutputMemo
:
'C:\Documents': No such file or directory
Then, OpenDialog1
isn't getting the full path with the spaces, or gcc can't locate it on the folder with spaces.
Any suggestion to help me on this?