I have been using Visual Studio for quite some time now, developing mainly for C++. I was often in need to create solutions, that contained multiple modules (projects) - for example utility library, that was consisted of couple .dll
files.
When there is a need for one module (A) to use another (B), there is standard pattern for this:
Linker
-> Input
-> Additional Dependencies
-> 'B.lib'
).Recently I started to play around with C#, because I decided to develop some GUI-based tools for my engine with it (it's much easier, than using C++ and external libraries like Qt or wxWidgets). I learned, that in C#, such dependencies are set using 'References':
I was very surprised, when I discovered, that this option is also applicable for C++ projects!
Indeed, after I created sample solution and set dependencies this way, everything was working fine, without any additional configuration like "Linker input" or something.
My question is: what does exactly this option do for C++ projects? I am interested in all profits and potential trade-offs.
I know already, that it causes linking output from other projects set as dependencies. Anything else? Perhaps some runtime dependencies between referenced modules? How does it affect generated output?
It was originally meant to only be used in C++/CLI projects. And did the exact same thing that adding references to a C# project did, you pick .NET reference assemblies that you need to get the project to compile.
But this confused a great many C++ programmers, they thought it should contain something generally useful. Probably because it is under the "Common Properties" heading. Lots of questions about it.
Fast forward to VS2010, a version that was unfinished. One of the few cases where a Microsoft project overshot its intended shipping date. They got an extra 6 weeks to work down the bug-list. But that wasn't enough, the feature that was supposed to make it easier to link dependencies was not actually implemented or disabled.
So at VS2012 they decided to do it a different way and make Add Reference useful to a native C/C++ project as well. You always pick a project reference, it needs to be a static library or a DLL project. One that produces a .lib file. And it automagically tells the linker to link that .lib file. Nothing else, it simply adds the .lib file to the linker command line. Works well.
Update: changed again for VS2015, it now has a References node. Right-click it to add references to another project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With