VS solution directory Structure setup and management

Source: Internet
Author: User

A medium-sized solution typically contains several projects, some of which produce static libraries, some output dynamic libraries, some for unit testing, and some that produce final application execution files. In addition, some third-party libraries are used, depending on the needs of the project. Therefore, a reasonable directory structure for the solution, not only can make the code management more organized, project members are also easier to work with each other, more importantly, can make the final application of the installation package, source code packaging release and transfer becomes very easy. Solutions and projects: from VC6 the VC series uses solutions (solution) instead of the original workspace for organizing and managing multiple related projects (project). The article begins by demonstrating a virtual solution and the directory structure we expect to get, and then using the VS Project setup feature to meet our needs step-after-step. Virtual Solutions:The virtual solution, named GMA, contains a dynamic link library project Chocolatemilk and an application project Puremilk, which requires a third-party library Log4cxx (Apache log4j C + + ported version for log output). Log4cxx is compiled in the form of a dynamic library, so we need 3 things for it, namely header files, import libraries (Log4cxx.lib, log4cxxd.lib), and dynamic link libraries (log4cxx.dll). Suppose we expect a directory structure such as: 1. GMA is the solution Catalog 2. Puremilk and Chocolatemilk are project directory 3. The Lib directory is used to store import libraries or static libraries (including third-party libraries and their own projects) 4. Include header file 5 for storing third-party libraries. The bin directory holds all dynamic link libraries and execution files, including its own outputs and third-party libraries, distinguishing between release and debug two versions. In addition, the process requires external data files and configuration files needed at startup, etc. can be placed in the directory 6. Temp is used to hold temporary makefile, where compile holds the obj file generated at compiler compile time, and link stores the linker's output file. The above directory structure clear, one side knows, when our program needs to make the installation package or to package the source release, it can make our life easier ^_^ we only need to package all the files in the "/gma/bin/release/" directory when we make the installation package. When we publish and transfer the source code, we can package all the files and directories under "/gma/" except the temp directory (or bin if you do not need to execute the file). Our needs are clear, but vs does not automatically do everything for us. However, we do not need to write a complex compilation script (makefile), simply modify the project's default settings.What we need VC to do for US includes: 1. Use "/gma/temp/compile/" as the intermediate Directory 2 used when compiling the project. Use "/gma/temp/link/" as the output directory for project links 3. When the project is an application, copy the execution file to "/gma/bin/release/" or "/gma/bin/debug/" at the end of the build, and when the project is a dynamic link library, in addition to copying the DLL to the Bin, copy the import library to "/gma/lib/" 4. When the project is an application, run the Execute file under "/gma/bin/debug/" or "/gma/bin/release/" while debugging, and use "/gma/bin/debug/" or "/gma/bin/release/" as the working directory First look at the macros that you can use in your project settings, which are commonly used:
ConfigurationName Configuration name, usually debug or release
IntDir Intermediate directory used by the compiler, output obj file
OutDir Output directory used by the linker
ProjectDir Project directory
ProjectName Project name
SolutionDir Solution Catalog
TargetDir directory where the destination output file resides
Targetext The extension of the target output
TargetFileName Target output file name, including extension
TargetName Target output name, not including extension
TargetPath Full path name of the destination output file

to set up chocolatemilkFirst :  1. Use "/gma/temp/compile/" as the intermediate Directory 2 used when compiling the project. Use "/gma/temp/link/" as the output directory of the project link    Note the highlighted part, first change the configuration to all configuration, so that we can also modify the debug and release parts;  output directory (output directory, linker) field fill in: $ (solutiondir)/temp/link/$ (ProjectName)/$ (configurationname)   Intermediate directory (intermediate directory, compiler) fields are filled in: $ (solutiondir)/temp/compile/$ (ProjectName)/$ (configurationname)  3. Copy the dynamic link library to "/gma/bin/release/" or "/gma/bin/debug/" after the build is finished, copy the import library to "/gma/lib/"   we usually add the letter "D" after the Debug version of the output library. To indicate that this is the debug version, in Debug configuration, modify the Import library field:   vs allows us to set the script to execute before and after the build, so in order to complete 3 we need to write the script executed after the build:   Fill in command line, under Debug Configuration:  copy $ (TargetPath) $ (solutiondir)/bin/$ (configurationname)/;copy $ (TargetDir) $ ( TargetName) D.lib $ (SolutionDir)/lib/; release configuration:  copy $ (TargetPath) $ (solutiondir)/bin/$ ( ConfigurationName)/;copy $ (TargetDir) $ (TargetName). Lib $ (SolutionDir)/lib/;  is set separately because the VC does not represent the macro name of the import library-_-p  ok, that's it, you can compile the Chocolatemilk project. It's all right, but make sure the target directory of the copy is set up beforehand.   Next we set up the application project puremilk : 1. Use "/gma/temp/compile/" as the intermediate Directory 2 used when compiling the project. The output directory that uses "/gma/temp/link/" as the project link first changes the configuration to the all configuration, which allows us to simultaneously modify the debug and release parts; output directory, linker) field: $ (solutiondir)/temp/link/$ (ProjectName)/$ (configurationname) Intermediate directory (intermediate directory, compiler) field filled in: $ ( SolutionDir)/temp/compile/$ (ProjectName)/$ (ConfigurationName) 3. After the build is finished, copy the execution file to "/gma/bin/release/" or "/gma/bin/debug/" in command line, under all configuration: Copy $ (TargetPath) $ (solutiondir)/bin/$ ( ConfigurationName); 4. Run the execution file under "/gma/bin/debug/" or "/gma/bin/release/" while debugging, and fill in the Working Directory command field with "/gma/bin/debug/" or "/gma/bin/release/": $ ( SolutionDir)/bin/$ (configurationname)/$ (targetfilename) Working directory fields fill in: $ (solutiondir)/bin/$ ( ConfigurationName)/So it's done, and now you can compile the executable and debug it.

VS solution directory Structure setup and management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.