PacktPublishing / Linux-System-Programming-Techniques

Linux System Programming Techniques, published by Packt
MIT License
96 stars 44 forks source link

Linking the math library needs to come after the file #1

Closed who8mypnuts closed 3 years ago

who8mypnuts commented 3 years ago

For the first example in chapter three, the gcc command should be: gcc interest.c -lm -o interest and then it will compile. Otherwise, an error will be thrown on some systems.

jackbenny commented 3 years ago

I've looked into it, and you are correct. Of the larger distributions, it's Ubuntu that's affected. Ubuntu has added the --as-needed flag to the linker, which affects the ordering of the libraries.

Thank you for bringing this to my attention, as there are several more places in the book that's affected by this. I'll contact Packt to work out a solution to this.

jackbenny commented 3 years ago

I've added an errata document showing all the places where this occurs, and described how to change it so it compiles. The errata is available here. There is also a link to it from the README file.

Thank you for reporting this!

jackbenny commented 3 years ago

This issue has been fixed in the book as of June/July 2021.