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.



3 responses

28 03 2008

Oh !!!!!!!! is it??

Then , Thats a good one…


28 03 2008

Nice tip. we have been using this for removing unwanted libraries.

Recently one of my colleague asked me he just got a warning like this.

warning LNK4089: all references to “MSVCIRT.dll” discarded by /OPT:REF

I was looking for a solution to resolve this issue. Because we are using inherited make files. Almost all required things are defined inside the common makefile. It’s hard to change that. Anyway AFAIK, this warning can be ignored.

31 03 2008

Hope this warning “warning LNK4089: all references to “MSVCIRT.dll” discarded by /OPT:REF” Comming ony in release build. I had the same issue. Solved in the similar way, but not exactly like this.. Any way thanx.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: