Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link library in Visual Studio, why two different ways?

I need to link library from one project into another, and it looks there are 2 ways, can you tell what is the difference and what is the consequence of having "true" in one setting and "false" in another (the same) setting?:

enter image description here

and another one: enter image description here

What is the difference, and do I need both setting set to "yes" or just one and if so which one?

like image 845
codekiddy Avatar asked Jan 30 '15 10:01

codekiddy


People also ask

How do I create a .LIB file in Visual Studio?

To create a static library project in Visual StudioOn the menu bar, choose File > New > Project to open the Create a New Project dialog. At the top of the dialog, set Language to C++, set Platform to Windows, and set Project type to Library.


1 Answers

A one-line explanation would probably be that the second option specifies something about how the first one works.

  • Link Library Dependencies set to Yes: if the solution is set up so that the current project has a dependency on another project that produces a .lib file, then that file will be linked in automatically.
  • Use Library Dependency Inputs set to Yes: useful mostly in Debug builds, when Incremental Linking is enabled. Normally, if a .lib generated by another project changes, and the current project depends on it, the linker can no longer link the current project incrementally (it's difficult for it to know how exactly the .lib changed). If you set this option to Yes, then the linker doesn't use the .lib file generated for the other project, but rather the individual .obj files that were used by the librarian to generate that .lib (as if the .lib didn't exist, and every object file from the other project were given to the linker individually, alongside the .obj files from the current project). This enables it to continue linking incrementally.

As far as I can tell, Use Library Dependency Inputs only makes sense if Link Library Dependencies and Enable Incremental Linking are both also set to Yes, and the current project depends on another project that generates a .lib file that changes often during development.

Additional information here and reference docs here.


UPDATE based on the comment from the OP:

As far as I can tell, the property entry under Project Reference Properties specifies the setting individually for each referenced project (whether to use the .lib from that specific project or not), while the one under Linker - General is the default setting for referenced projects.

For example, if you set the one under Linker - General to No and add a new referenced project, then, for that project, the setting under Project Reference Properties will default to False. However, the settings for referenced projects that were added before keep their individual setting.

I expect the individual setting under Project Reference Properties to override the default from Linker - General, but I haven't actually tested this bit.

like image 155
bogdan Avatar answered Jan 01 '23 12:01

bogdan