Stop Microsoft

Miscellaneous => Programming & Networking => Topic started by: sAvAgE on 30 September 2002, 19:34

Title: gcc Basics
Post by: sAvAgE on 30 September 2002, 19:34
ok I am stuck with gcc version 3 I understand how to put in the arguments for compiling however this is what I am doing.
for openGL glut I am doing this to test the code I am writing

for example
linux@user$ gcc -lGL -lglut main.c
linux@user$ ./a.out

then the proggy runs .. what is the command to actually compile the main.c as a program and not use the input output link as an app?
Title: gcc Basics
Post by: flap on 30 September 2002, 20:47
Sorry; I don't understand the question. The command to compile main.c as a program is exactly what you've done.
Title: gcc Basics
Post by: voidmain on 30 September 2002, 20:52
"a.out" *is* a program.  I don't understand the question either.  You can either rename "a.out" to something else, or use the "-o" parameter to gcc to have it automatically compiled/linked to a name other than "a.out".
Title: gcc Basics
Post by: sAvAgE on 30 September 2002, 21:03
so what you are telling me is all I would have to do is rename the a.out file?
user@linux$ mv a.out program ?
Title: gcc Basics
Post by: sAvAgE on 30 September 2002, 21:07
thanks void yes you guys were right the a.out is a program . I guess the main question is how do I get gcc to create a makefile installation of the program using glut?

I hope this question resolves my original question
Title: gcc Basics
Post by: voidmain on 30 September 2002, 22:01
Hmmmm, gcc doesn't "create a makefile installation".  gcc is a compiler.  Still not exactly sure what you are getting at but it sounds like what you might be asking for is "how do I create a Makefile so I can type 'make' and it will compile/link my program with the necessary libraries?". If your question is how to create a Makefile you might want to look here:

http://www.gnu.org/manual/make-3.79.1/html_mono/make.html (http://www.gnu.org/manual/make-3.79.1/html_mono/make.html)

A simple example of a Makefile for your program might look like this:

Code: [Select]

If you copy the above code into a file called "Makefile" in the same directory as your source.  Change the "myglprog" to whatever you want to resulting program to be named then when you type "make" it will compile/link the main.c program with the GL/glut libraries into a program called "myglprog".  If you type "make clean" it will erase the "myglprog" program.

NOTE: The whitespace in my sample might copy into your source as spaces, if they do you need to make sure you change that whitespace to a "tab" rather than spaces. It should be a single TAB in front of the line that start with "gcc ... ..." and the line that starts with "rm ... ...". It will not work if you leave them as spaces.

[ September 30, 2002: Message edited by: void main ]

Title: gcc Basics
Post by: sAvAgE on 1 October 2002, 19:15
Hey thanks void Much appreciated.  (http://smile.gif)  this Helps a lot