How to remove unwanted libraries from project settings.

28 03 2008

Icon Description
Usually in the project settings, we will provide a list of .lib files that the project needs to compile. For small projects it’s manageable. But for big project which uses a lot of 3ed party frameworks, the .lib list can grow and may contain unwanted libraries which are not used any more. Even though an extra library in project setting is harmless, it may end up messing up the project setting. Some clients even have strict project setting rule – project settings should not include unused libraries.

Icon How Can I Do It?
One method is error and trial. Remove each library by hand and compile. If you won’t get any error then you can remove it. Or else you should try Masters Method!

1) Take project settings.
2) Take Link tab.
3) In the “project options” editbox add the switch – /verbose
4) Rebuild the project
5) Now in the output window you can see a lot of messages other than normal build.
6) Find the pass 2 section in the output messages. It will be almost same as follows

Start Pass2
End Pass2

7) In the pass 2 section, linker will emit all used libraries.
8 ) In the above e.g. the lib files needed
are “kernel32.lib” and “LIBCD.lib”
9) So you’ve found the required library files!
10) Add them to “object/library modules:” editbox of linker settings.
11) Don’t forget to enable “ignore default libraries” options of linker. Because by default the linker links a set of default libs to the project. Those libs are no more needed!
12) Your project is free from unwanted libraries.

Now the choice is yours.Want to go for “Error and trial” or “Masters Method”? 😉

Targeted Audience – Advanced.

See the assembly code generated for your source.

24 03 2008

Icon Description
For die-hard debugging purpouse and for learning the internals, usually we need to refer the assembly code generated by the compiler.

Icon How Can I Do It?
Add compiler switch /FAs in the project settings. It will generate .ASM files for each of your .cpp files with source code and inline assembly. See the following steps.

1) Take project setting by pressing Alt+F7
2) Take C/C++ tab
3) To the Project Options editbox, add /FAs.
4) Recompile the project.
5) Take the release or debug directory, you can see .asm files. 😉