Compilation

Compiling code can be challenging. Compiling legacy code can ruin your day. However, it is often well worth the effort to compile legacy code rather than writing your own.

Motivation: If a legacy code has withstood the passage of time, it is probably:
1. correct
2. difficult to rewrite.
It is essentially impossible to write complicated code correctly fast. Designing a good test suite that checks all boundary cases takes TIME. By the time your new code is complete and correct, it may not be far from becoming legacy. Further, compilation skills are transferable. After one monster is slain, it becomes much easier to tackle the next.

Tricks:

  1. Compiler flags: -DADD_ v.s. -DADD__
  2. Library links: -L/lib to add folder /lib, -lname to link /lib/libname.a
  3. View library: nm libname.a

Examples:

  1. Quantum Espresso
  2. SPRNG v1.0
  3. UPI