GCC and run program

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
-LG-
Posts: 6
Joined: Tue Nov 18, 2003 8:23 pm

GCC and run program

Post 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?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you mean: How do I run the program I just compiled?

$BaseName
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Isn't the executible a.exe by default? I'd think you'd need to pass in something like -o $BaseName.exe
I choose to fight with a sack of angry cats.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
-LG-
Posts: 6
Joined: Tue Nov 18, 2003 8:23 pm

Post 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!
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post 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
I choose to fight with a sack of angry cats.
-LG-
Posts: 6
Joined: Tue Nov 18, 2003 8:23 pm

Post 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...
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

And you won't be able to get input in. There's a few threads over in the java forum on why.
I choose to fight with a sack of angry cats.
-LG-
Posts: 6
Joined: Tue Nov 18, 2003 8:23 pm

Post by -LG- »

Sorry I don't know where this should be.
Can you post it here for c as well?
Post Reply