简体   繁体   中英

Project/Solution setup in the Visual C++ IDE

I'm looking for advice or references on how to setup correctly (and rather elegantly & less hacky) a multi-C/C++-project solution under the Visual C++ IDE. For example, I'm concerned about absolute search paths and would prefer to use relative paths and/or make use of proper variables à la $(soandso) to make the solution/project work regardlessly of where it's stored exactly in the filesystem. But I don't know how I can achieve this.

The solution I'm currently dealing with contains two projects. One DLL project and one other commandline application project which makes use of the DLL. I'm wondering how I should setup all the paths and links -- not just to make it work for me, but to make it work for everybody else who copies my solution folder somewhere onto another harddrive into another folder (etc).

What you're looking for is something Visual Studio actually does by default. All output directories are relative to your solution:

  • Output Directory: $(SolutionDir)$(Platform)\\$(Configuration)\\
  • Intermediate Directory: $(Platform)\\$(Configuration)\\
  • Target Name: $(ProjectName)

Alternatively you could place these directories outside the source tree, to avoid polluting your working copy (I'm using SVN terminology here). You could do this by using relative path specifiers and macros like ..\\$(SolutionDir)

It's kinda hard to answer your question, if you could be more specific about what you're trying to achieve then I could give you a better answer.

So as @Nikola has mentioned, it does it all in VS already! The best way that I can tell you is if you want to make these two projects in the same solution:

1) create original solution with either the DLL or Client soltion
2) right-click on the solution (NOT the project) in the solution manager -> add -> new/existing project
3) add/create other project

As far as how to add a reference to the DLL in the client code...VS does it too. Heres the steps to take for that:

1) right click on client project
2) references
3) "Add new reference" - this will list the projects in the solution...click on the DLL project
4) "OK"

This will automatically make references to the DLL via relative paths, and since they're packaged together in the same solution, anyone who opens/uses the solution (or who install the code if you use release build) will also have the DLL referenced.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM