开发者

Building two C++ apps that use the same dll in vs 2010

I have apps A and B, both use dll D.

A, B and D are C++ projects in vs 2010.

A.sln and B.sln are the solution files that build apps A and B.

In both A and B there is a reference to the dll D.

The expected locations for the apps and dll are (assuming Debug builds):

A/Debug/A.exe

A/Debug/D.dll

B/Debug/B.exe

B/Debug/D.dll

Here comes the weird part: when I rebuild (or even clean) solution B, it somehow

deleted A/Debug/D.dll, even though the two apps are not related in any way.

Is there a way to instruct vs t开发者_如何学运维o only remove D.dll under B when rebuilding B?


What is the hint path for Solution B's Reference to D?

If your hint path points to Solution A, that is your problem. Delete the reference, copy D.dll from wherever it is into your Solution B folder, and then rebuild the reference using that path, rather than the Solution A path.


Did you create the project by copying the *.vcproj and renaming a few things? If so, then you probably have a collision with the GUID used to identify the project. (This is a non-rare problem at a number of development shops.)

Microsoft uses the GUID, which is cached in the Windows registry for each project built on that machine, to "look up" the referenced project and find it on your hard drive. (Thus, *.sln files won't "break" when the projects they reference are moved around on the hard drive; similarly, projects can reference other projects this way, and not "break", as you move stuff around.)

Recall that each project has a GUID that is globally/universally unique to identify the project (if you have a collision, it would be that one), and another GUID that identifies the "project type" (e.g., DLL, EXE, .NET assembly, etc.) There are additional GUIDs to identify "sets of files" within the project, but I haven't figured out how those are used (yet).

Microsoft lists some of the project type GUIDs at: http://msdn.microsoft.com/en-us/library/hb23x61k%28v=vs.80%29.aspx

...and you can get a more complete list of the thirty-or-so by searching the web, like:

http://onlinecoder.blogspot.com/2009/09/visual-studio-projects-project-type.html

The "unique-to-project" GUIDs are just generated through any GUID-generator, so they are expected to be truly unique.


What about solution A? What happens when you rebuild it? Does it delete the DLL?

If not, check if:

  1. The D project is part of solution A (or not).
  2. The Project Dependencies of D, A.
  3. The 'References' and appropriate Linker settings.

If there is inconsistency against solutions A, B; you need to apply same thing in solution A.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜