Author Topic: gcc Basics  (Read 1222 times)

sAvAgE

  • Member
  • **
  • Posts: 25
  • Kudos: 0
    • http://Not yet
gcc Basics
« 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?
Looking for 4-Play? Upgrade your O/S, Billy is Waiting for you.

flap

  • Member
  • **
  • Posts: 1,268
  • Kudos: 137
gcc Basics
« Reply #1 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.
"While envisaging the destruction of imperialism, it is necessary to identify its head, which is none other than the United States of America." - Ernesto Che Guevara

http://counterpunch.org
http://globalresearch.ca


voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
gcc Basics
« Reply #2 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".
Someone please remove this account. Thanks...

sAvAgE

  • Member
  • **
  • Posts: 25
  • Kudos: 0
    • http://Not yet
gcc Basics
« Reply #3 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 ?
Looking for 4-Play? Upgrade your O/S, Billy is Waiting for you.

sAvAgE

  • Member
  • **
  • Posts: 25
  • Kudos: 0
    • http://Not yet
gcc Basics
« Reply #4 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
Looking for 4-Play? Upgrade your O/S, Billy is Waiting for you.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
gcc Basics
« Reply #5 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

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 ]

Someone please remove this account. Thanks...

sAvAgE

  • Member
  • **
  • Posts: 25
  • Kudos: 0
    • http://Not yet
gcc Basics
« Reply #6 on: 1 October 2002, 19:15 »
Hey thanks void Much appreciated.    this Helps a lot
Looking for 4-Play? Upgrade your O/S, Billy is Waiting for you.