Computer Science Canada

Help with compiling

Author:  Windsurfer [ Sun Dec 10, 2006 2:01 pm ]
Post subject:  Help with compiling

Hi
Maybe this should belong in general... but...
In my programming class, we use Dev C++. All we've been taught about this API is to use F9 to compile and run.
However, I would like to use Notepad++http://notepad-plus.sourceforge.net/ to write code. Now, i know how to use the command prompt, sort of, and how to compile and run a program. Something like
code:

g++ myprog.cpp -Wall -o myprog.exe

and then to run it, use something like
code:
start myprog.exe

(PS i'm running WinXP)
Now, it works, sure, but it is tedious compared to just pressing F9. I was hoping someone knew how i could, in windows, compile and run in one line.
The reason I want it in one line is so that I can integrate the g++ compiler with Notepad++.
Anyone know?

Author:  wtd [ Sun Dec 10, 2006 2:20 pm ]
Post subject: 

First off, you only need to type "myprog" to execute the resulting executable.

Secondly, you can create makefiles to make this whole process potentially simpler.

Your makefile would look something like:

code:
CC = g++
LN = g++

CXX_FLAGS = -Wall

EXE_NAME = myprog.exe
DELETE = del

all : myprog

myprog : myprog.o
        ${LN} myprog.o -o ${EXE_NAME}

myprog.o : myprog.cpp
        ${CC} ${CXX_FLAGS} myprog.cpp -o myprog.o

clean :
        touch myprog.o
        touch ${EXE_NAME}
        ${DELETE} myprog.o ${EXE_NAME}


Then you can build your app with a simple:

code:
make


And when you want to get back to a clean base to build it again:

code:
make clean

Author:  Windsurfer [ Sun Dec 10, 2006 3:03 pm ]
Post subject: 

Uhm, okay... and I need to get "GNU make" for this? and how do I apply this to a program like Notepad++ as a shell command?

Author:  wtd [ Sun Dec 10, 2006 4:28 pm ]
Post subject: 

Keep a cmd.exe window open. Keep a Notepad window open. Edit in Notepad++, compile in the command prompt window.

Author:  Windsurfer [ Sun Dec 10, 2006 7:29 pm ]
Post subject: 

Well that's annoying. I'm sure there is a way to do it within Notepad++. I'm switching to perl instead... Razz

Author:  wtd [ Sun Dec 10, 2006 7:43 pm ]
Post subject: 

Perl's a fine language too.

But not having a fancy IDE isn't a huge issue. Plus, it doesn't get much more simple than a text editor and a command-line.

Author:  md [ Sun Dec 10, 2006 11:32 pm ]
Post subject: 

text editor + command line is great. The only problem I have is that terminal windows are too small at 8- characters wide, errors are much easier to read when they are not spread over 6 lines.

Author:  wtd [ Sun Dec 10, 2006 11:33 pm ]
Post subject: 

Windows command windows can be made wider. Right-click the titlebar and select properties.

Author:  md [ Mon Dec 11, 2006 2:23 pm ]
Post subject: 

Or you can do like me and use linux Wink Variable sized terminals are wonderful!

Author:  wtd [ Mon Dec 11, 2006 2:36 pm ]
Post subject: 

Yes, but one has to give Windows credit where it's due. Doing that just makes it look even less impressive, in my opinion. Smile


: