Friday, June 08, 2007

Some Makefile Tips

When write a non-trivial program, you may need to write some libraries and then applications. If you are using static linking, make sure that you specify dependencies clearly in the Makefile otherwise you are going to waste lots of time during debugging.

You modify the library code, then type 'make', everything seems fine. But
somehow your changes didn't go into the binary.

Normally you put the library code into a separate directory (which is a good practice) and the Makefile will produce a libx.a library file. Then, the application will use this library using '-L'. A common misktake is that Make doesn't know the target program depends on the libx.a file.

No comments: