This manual provides a complete tutorial introduction to the GNU C and C++ compilers, gcc and g++. Many books teach the C and C++ languages, this book teaches you how to use the compiler itself. All the common problems and error messages encountered by new users of GCC are carefully explained, with numerous easy-to-follow "Hello World" examples. Topics covered include: compiling C and C++ programs using header files and libraries, warning options, use of the preprocessor, static and dynamic linking, debugging, optimization, platform-specific options, profiling and coverage testing, paths and environment variables, and the C++ standard library and templates. Features a special foreword by Richard M. Stallman, principal developer of GCC and founder of the GNU Project. All the money raised from the sale of this book will support the development of free software and documentation.
Books on C programming often contain a sentence which reads something like, "see your compiler's manual for more." That always sounded like a good idea, but I could never be bothered to read the actual manual when answers to my immediate questions were always available online.
Unfortunately, that always left me with gaps in my understanding - gaps that weren't specific questions per se, but information I didn't know that I didn't know.
I've always wanted to fill in the gaps, so I took a chance on a cheap used copy of this book. I'm happily surprised at how glad I am that I did. I really enjoyed this book a lot. It's short and chock-full of examples and exercises.
Read this with a computer at hand. Do the exercises. I'm amazed at how much ground Gough covers and how concise he manages to be. Thanks to this book I've finally:
* Learned how to compile for debugging and used GDB to debug a program
* Generated core dumps and used them to see where a program crashed
* Examined the output of the preprocessor and assembler
* Compiled for various levels of optimization and compared them
* Created a C library and used it
* Profiled and viewed line-by-line execution coverage of programs
* Viewed the symbol table of an executable
* Attached GDB to a running process (with an infinite loop) from another session and took control of it
As a casual user of C, I had never done any of these things before.
I won't remember how to do everything, but I will remember that I can. I can get the book out again when I need it. Because the examples are so short, I think this will make an excellent go-to reference.
A few things didn't work as written and I suspect that's because my "Revised and Updated" edition was written for GCC v3.3.1 and I'm running 4.8.2, but I simply ignored those things and continued on. They had no effect on my ability to learn the concept.
Found this by chance at a used bookstore. Unless you take a course in compilers or gravitate to manuals, you may be dogged by a feeling that you are perpetually unclear - and will forever be unclear - about those stages on the way to making an executable from C or C++ code: preprocessing, compiling, assembling, linking, optimizing, etc. You know, all the stuff a good IDE hides from you most of the time, until it doesn't.
My pressing questions were mainly about the different kinds of linking. I'd read many forum threads, blog articles, tutorials, and so on, but nothing I could find anywhere online was remotely as good as this book. It's around 100 pages in chapters of 100 percent pith. More to the point, it's the most pleasant and clarifying experience I could ever expect from a book about a compiler. There's probably tons not included, but the author always tells you where you can sink your fangs into a relevant manual, and you'll get many basic commands, flags, warnings, and error messages, along with a nice high-level sketch of the overall process from code to execution.
The book is exactly what it says, an introduction. It won't teach you how the compiler itself works - it's a user-level overview that will serve many people well as a mug-side reference. It won't teach you how to write C/++ either, though there are enough simple examples that it could help refresh your memory. What it will do is clear up the confusion about compiler and linker flags, header files, source files, object files, libraries, pathing, environment variables, symbol tables, optimization, architectures, and such ubiquitous concerns that can feel esoteric. The book will get you comfortable with what goes on underneath the IDE at the command line so that you won't be afraid of those settings. It covers the basics of makefiles but does not go into autotools or more advanced build automation. The book will leave you with a better sense of what goes on with other compiled languages, as C/++ has been such a standard for so long, and concepts like static and dynamic linking transcend language barriers.
Highly recommended if you're learning C/++ or getting back into it, and fun to read despite the serious focus. It actually helped me solve a technical problem I'd been struggling with, linking some C++ libraries to Java code via SWIG and JNI.
If you have some C/C++ under your belt, and wonder how you should use gcc to compile that - read this book. Otherwise, it might be a loss of your time. It prances around describing not only basics of gcc, but also few related utilities. It contains useful knowledge, but those that are interested "how does the compiler work" might be left not entirely satisfied. This way or another, there's solid chunk of introductory material and the book is available online for free.
A gentle introduction to the GCC compiler with introductory tutorials to its ancillary tools gdb, gcov and gprof. Very useful for the novice developer and highly recommended for graduates starting out on this development platform.
. . Contents Foreword 1. Introduction 2. Compiling a C program 3. Compilation options 4. Using the preprocessor 5. Compiling for debugging 6. Compiling with optimization 7. Compiling a C++ program 8. Platform-specific options 9. Troubleshooting 10. Compiler-related tools 11. How the compiler works 12. Examining compiled files 13. Common error messages 14. Getting help Further reading Acknowledgements Other books from the publisher Free software organizations GNU free documentation License Index