Closed who8mypnuts closed 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.
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!
This issue has been fixed in the book as of June/July 2021.
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.