Page 1 of 1

GCC and run program

Posted: Thu Nov 20, 2003 12:53 pm
by -LG-
I configured TextPad to compile with gcc -Wall a c file

C:\MinGW\bin\gcc.exe
-Wall $File
$FileDir

How can I start the program with the same call?

Posted: Thu Nov 20, 2003 1:17 pm
by ben_josephs
Do you mean: How do I run the program I just compiled?

$BaseName

Posted: Thu Nov 20, 2003 3:03 pm
by talleyrand
Isn't the executible a.exe by default? I'd think you'd need to pass in something like -o $BaseName.exe

Posted: Thu Nov 20, 2003 3:17 pm
by ben_josephs
Of course! Talleyrand is quite right.

To get gcc to name the executable file after the source file (instead of the default a.out), you need to give it parameters:

-Wall -o $BaseName.exe $File

or some such.

Posted: Thu Nov 20, 2003 6:05 pm
by -LG-
ben_josephs is right: I meant how do I run the program I just compiled?
When i click to GCC , TextPad should compile the program and run it!

Posted: Thu Nov 20, 2003 9:04 pm
by talleyrand
Ben and I were discussing the filename of the executible. What you are asking for is to hit the button, compile your code and then run it, yes? If so, what you probably need to do is either make two tools, one you have already with gcc. The other would call the program located... Nevermind, that won't work. That leaves the alternative which is the creation of a batch file to do the two commands. My batch making skills are extremely rusty but this ought to do the job (worked for me just now). Save this out as a gcc.bat (or whatever) and set your tool parameters up as
$BaseName.exe $FileName

Code: Select all

@echo off

rem %1 is the name of the executible
rem %2 is the name of the source file
E:\mingw\bin\gcc.exe -Wall -o %1 %2

rem Not sure if call is needed here or not.
call %1 4

Posted: Thu Nov 20, 2003 9:33 pm
by -LG-
I think it's easier when there are 2 buttons.
1. button: compile
2. button: run

The compile statment is the same as I wrote before
And for run I added a new DOS-line

Parameter: $BaseName.exe
Basedir: $FileDir

Q:
I cannot input numbers or text...
the program should now open in a dos box...

Posted: Fri Nov 21, 2003 2:03 am
by talleyrand
And you won't be able to get input in. There's a few threads over in the java forum on why.

Posted: Fri Nov 21, 2003 4:05 pm
by -LG-
Sorry I don't know where this should be.
Can you post it here for c as well?