Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
*I dont know anything about the source code*
i have a project in which nafxcw.lib along with some other libs are added into linker library dependencies.when i am converting that project from vs2008 to vs2017,the size of exe generated in 2017 is changed from around 1700 kb to around 4000 kb.(i am taking about release not debug).

when i removed nafxcw.lib from linker dependencies,the size got reduced to around 2000kb.
If i am linking this lib the size getting increased and if i removing the size getting reduced.In both cases the generated exe is working fine.
i dont understand if there is no use of that lib why the size of exe in increasing?

What I have tried:

i dont understand if there is no use of that lib why the size of exe in increasing?
Posted
Updated 20-Sep-17 22:23pm

NAFXCW is the static MFC library. If you specify that in the project settings, the code of the used functions from that library will be copied to your application and increase the size.

When not linking with that library, the functions are provided by the MFC DLLs.

However, there is usually no need to specify the static library in the project settings. Use the corresponding project property instead.

Because you have converted the project from 2008 to 2017 and saw a large increase in size, it looks like the library has been left over in the settings where 2008 ignores the entry and uses the DLLs while 2017 respects the settings and links it.
 
Share this answer
 
Comments
Naveen_vemuri 21-Sep-17 4:31am    
But if i remove nafxcw.lib in vs2008,then it is giving errors but not in vs2017.why?
If it use some functions from that lib,then it should give error right?
Jochen Arndt 21-Sep-17 4:38am    
It looks like it has been added manually in 2008 instead of using the mentioned project property. 2017 might be smart enough to detect that and use the DLL when removing the library.

2008: Remove the library and check the MFC library property (select DLL or static; I guess it is actually set to don't use MFC). Then it should compile and link.

2017: Do it similar.

The project configurations change with the VS versions and the conversion might not catch all cases.
Naveen_vemuri 21-Sep-17 6:11am    
(VS2017)I just noticed this: if i remove nafxcwd.lib in debug mode from linker dependency,i am getting errors but in release mode even if i removing or adding(nafxcw.lib)there are no errors.why?

(In both vs2008 and vs2017)Also,I tried the above points u mentioned.In that the program is running fine if i remove libs and use a shared dll but giving errors for static.why?

can u give me clear picture about these:
1)standard windows libraries.
2)use of mfc as static library.
3)use of mfc as a shared dll.
Jochen Arndt 21-Sep-17 6:18am    
I can't tell you why because I don't have your project.

As already said:
It looks like your project uses manual settings instead of the preferred MFC library setting. Then you are converting it to 2017 which might loose some settings and/or 2017 behaves differently as 2008 due to changings in the project handling. Note also that the settings may different for release and debug build resulting in different effects.

As already suggested:
Remove the library definition and use the general setting (static or DLL) for the MFC instead.

A good developer would have provided some documentation about the project settings and why he chooses specific options.
You are moving from an old version of the compiler and libraries to a newer one with more functionality, so the size is almost guaranteed to increase.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900