Take the 2-minute tour ×

I downloaded a set of source code for a program in a book and I got a makefile. I am quite new to Linux, and I want to know whether there is any way I can see the actual source code written in C?

Or what exactly am I to do with it?

share|improve this question
Did you say "source code for a book" ? Should that have been "source code from a book" ? –  pavium Dec 20 '09 at 9:58
ya sorry i meant source code for the programs in a book –  yuneek Dec 20 '09 at 10:01

3 Answers 3

It sounds like you may not have downloaded the complete source code from the book web site. As mentioned previously, a Makefile is only the instructions for building the source code, and the source code is normally found in additional files with names ending in .c and .h. Perhaps you could look around the book web site for more files to download?

Or, since presumably the book web site is public, let us know which one it is and somebody will be happy to point you in the right direction.

share|improve this answer
the book is opengl superbible, and i am having trouble getting the codes in the book to work by typing it myself so i was wondering if i get the source code i cud find out ma mistakes. the link that i got is starstonesoftware.com/OpenGL –  yuneek Dec 20 '09 at 10:12
And which file from that page did you download? –  Greg Hewgill Dec 20 '09 at 10:14
the last one linux make files –  yuneek Dec 20 '09 at 10:16
I just downloaded that and there are zillions of example source files in there. I'm not sure how you could miss them all. For example, the source code for one of the samples in Chapter 2 appears to be in SB-LinuxSrc/examples/src/chapt02/simple/simple.cpp. –  Greg Hewgill Dec 20 '09 at 10:23
oh oh i am so sorry i was in the wrong folder i apologize for ma studpidity thank you very much sir i appreciate it so much wont make such stupid mistakes again:) thank you again –  yuneek Dec 20 '09 at 10:28

A Makefile does not contain any source itself. It is simply a list of instructions in a special format which specifies what commands should be run, and in what order, to build your program. If you want to see where the source is, your Makefile will likely contain many "filename.c"'s and "filename.h"'s. You can use grep to find all the instances of ".c" and ".h" in the file, which should correspond to the C source and header files in the project. The following command should do the trick:

grep -e '\.[ch]' Makefile

To use the Makefile to build your project, simply typing make should do something reasonable. If that doesn't do what you want, look for unindented lines ending in a colon; these are target names, and represent different arguments you can specify after "make" to build a particular part of your project, or build it in a certain way. For instance, make install, make all, and make debug are common targets.

You probably have GNU Make on your system; much more information on Makefiles can be found here.

share|improve this answer
thank you sir, but again what is the use of me getting a makefile. i mean i downloaded the file because they told it is the source code for many examples and if i dont get the source code then what am i supposed to study? i am totally new to this thats y, if the que is stupid please bear me. what am i actually supposed to do with this . i did use the command and i got some filenames and all, then what am i supposed to do? –  yuneek Dec 20 '09 at 9:59
The Makefile is no good by itself. It tells the system how to turn the .c and .h source code files into object code, and probably link them together into a single executable. The Makefile does not contain any C code. My guess is that those are lurking somewhere on the site you got the Makefile from. If the site is indexed by Google, Google Code Search (google.com/codesearch) may be helpful. Type in a filename you got from the Makefile or a snippet of code or comment you expect, and append "lang:c" and/or "site:sitewheremycodeis.com" to the query. –  Matt J Dec 25 '09 at 22:11

It looks like you also need to download the SB-AllSource.zip file. Then use make (with the Makefile that you've already downloaded) to build.

share|improve this answer
sir, what will happen after i build? what am is supposed to do with it? –  yuneek Dec 20 '09 at 10:23
sir got it thank you for ur help it was just in a different folder :) –  yuneek Dec 20 '09 at 10:29

Your Answer


