views:

8407

answers:

2

I have a batch file to compile and link all of my code. It contains the following:

@echo off
nasm -f aout -o start.o start.asm
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c
ld -T link.ld -o kernel.bin start.o main.o scrn.o
pause

Problem is, when i run it it just prints all this out as text. It's definitely a batch file. it has the .bat file ending, and in notepad++, the syntax for @echo off and pause are being highlighted without being set manually. Is this a windows 7 bug? or am i doing something wrong?

+1  A: 

A simpler example
Windows 7 installed
Using cygwin to get gcc

I used the following batch script:

PATH = %PATH%;C:\cygwin\bin;
gcc test.c

on the following c file:

main() {
        printf("hello, world");
}

And it compiled fine.

My Conclusion
Windows 7 batch scripts work pretty much like in previous versions of windows.

Simple things that could trip you up
Gcc is not installed by default on Windows, I suggest either cygwin or mingw
Gcc is not on the PATH by default after you have installed gcc, you can add it to the system's environment variable or add it in your batch script (using something like the first line of the batch script I just used).

John Mulder
I have djgpp setup in my path. if i just type the command manually, it works fine. but it does nothing but print the line if i do it in the batch file
The.Anti.9
+3  A: 

Are you running from a command line or by double-clicking in Explorer?

Maybe you have the Edit action set as the default?

Try right-clicking and selecting Open.

EDIT: Maybe your line terminators are messed up. Windows expects CRLF.

In Notepad++:

  • Click View->Show End Of Line.
  • If they are not CRLF, click Format->Convert to Windows Format.
aphoria
i've tried both and they both do the same thing
The.Anti.9
Maybe your line terminators are messed up. I think Windows expects CRLF.In Notepad++, click View->Show End Of Line. If they are not CRLF, click Format->Convert to Windows Format.
aphoria
Yes, that was it. thanks
The.Anti.9
@aphoria: You should move your comment to the answer body, since that was the actual solution.
configurator
@configurator: Good point...done.
aphoria