"Wow, cool! My First Linux Program! But...How do I compile it?" Ahhh...I'm so glad you asked, my son (or daughter). Linux mainly uses a compiler called "gcc" (GNU C Compiler). It is probably the most ANSI-C Compilant compilers I've ever used. Now, wanna compile your program? Go to a shell, cd to your directory and type: gcc linux-helloworld.c It will generate a file called a.out so, what I expect you to do next, is type ./a.out and see the results. Happy? Heh, well I was. There are many more options you can send to gcc, I will cover a few here. -c will compile the code to an object file, not an executable. -o -l -L -O -pendantic -W -Wall should be used if you want gcc to tell you about your coding (dis)abilities.
So, an example program that is compiled with SDL would look a bit like this.
Wow! It compiled! How cool is that? Well I think it is very cool. If you're confused at all of the other parameters, then it's ok. Most of them are SDL specific and will be covered in later tutorials. But...wouldn't it really suck to type in all of that every time you want to compile? What if you had a few hundred .c files? Wouldn't it take very long? Along comes Make to the rescue!
|
|