4

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?

2 Answers 2

5

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.
Sign up to request clarification or add additional context in comments.

2 Comments

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: You should move your comment to the answer body, since that was the actual solution.
1

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).

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.