Chapter 1. Set Yourself Up for Easy Compilation
Look out honey ’cause I’m using technology.
Iggy Pop, “Search and Destroy”
The C standard library is just not enough to get serious work done.
Instead, the C ecosystem has expanded outside of the standard, which means that knowing how to easily call functions from common but not-ISO-standard libraries is essential if you want to get past doing textbook exercises. If you want to work with an XML file, a JPEG image, or a TIFF file, then you will need libxml, libjpeg, or libtiff, which are all freely available but not part of the standard. Unfortunately, this is the point where most textbooks taper off and leave you to work it out for yourself, which is why you can find C detractors who will say self-dissonant things like C is 40 years old, so you have to write everything from scratch in it—they never worked out how to link to a library.
Here is the agenda for the chapter:
- Set up the requisite tools
- This is much easier than it was in the dark days when you had to hunt for every component. You can set up a full build system with all the frills in maybe 10 or 15 minutes (plus all the download time to load so much good stuff).
- Compile a C program
- Yes, you know how to do this, but we need a setup that has hooks for the libraries and their locations; just typing
ccmyfile.cdoesn’t cut it anymore. Make is just about the simplest system to facilitate compiling programs, so it provides a good model for discussion. I’ll show you the smallest ...