wiki:DevelopingWithWindows

Developing with Windows / Visual Studio

Getting Subversion

First thing you will want to do is get a working version of Subversion to download Cloudy. TortiseSVN is a great tool on Windows that optionally includes the command line tools you will need to checkout and update cloudy. Other versions of SVN are also available as listed on the Apache Subversion site. Instructions for downloading Cloudy using SVN are on the DownLoad page.

Getting Visual Studio

Visual Studio 2010 and 2012 are currently (at time of writing) available from Microsoft's website and both have been shown to work. Instructions on compiling cloudy with Visual Studio 2010 are on the respective CompileCode pages, and the same options work for Visual 2012, except setting the data path through the compiler which still requires double quotes.

Compiling with Visual Studio

Most of this information is found on the CompilingCloudyC13 page, but it also here to review.

When initially creating a project select "Win32 Console application" and when given a wizard or the option for Application settings select "empty project"

Once the project is created add the downloaded source and header files in the source directory to the project, Project>Add Existing Item, then remove the Test*.cpp files or else it won't compile.

To add the path either edit path.h to point to the data directory (deprecated since version C15) OR in Project>Properties>Configuration Properties>C/C++>Preprocessor>Preprocessor Definitions add

CLOUDY_DATA_PATH="C:\\cloudy\\trunk\\data\\"

where this points to the actual data directory or the code will not run properly.

To set the other compiler options go to Project>Properties>Configuration Properties>C/C++

Under "C/C++>Optimization" set "inline function expansion" to "only_inline"

Under "C/C++>General" set "Debug Information Format" to "Program Database (Z/i)"

Under "C/C++>Advanced" disable warnings 4244; 4305; 4355;

If you plan on compiling in multiple threads, under "C/C++>General" you will want to set "Multi-Processor Compilation" to "Yes (/MP)", but you will also have to under "C/C++>Code Generation" change "Enable Minimal Rebuild" to "No (/Gm-)" as the two options are incompatible. The /MP option is also incompatible with the #import, /E, /EP, /showIncludes, and /Yc, but in the versions tested these were not used by default.

If you do are using Visual Studio 2010 and do not have Service Pack 1 (SP1) installed, you will receive a LNK1123 error upon compiling. This can be resolved by either changing Configuration Properties > Linker > General > Enable Incremental Linking to "No (/INCREMENTAL:NO)" or by installing SP1. Note that if SP1 is installed, 64-bit compilers will be removed but can be re-added with the VS2010 SP1 Compiler Pack.

Optimization

Optimization generally has given only a marginal speed increase, but can be enabled by in "C/C++>Code Generation" setting "Basic Runtime Checks" to "Default" and in "C/C++>Optimization" changing "Optimization" to the desired setting.

Using the Command Line

Visual Studio comes with a special command prompt environment for certain tasks. This command prompt can be accessed through the start menu or through the IDE, but to access it without either you must run

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat

through a command prompt to set the environment. The number after "Microsoft Visual Studio" will be 10.0 if you are using VS2010.

After running this batch file, the command prompt it was run in will have access to VS commands and most importantly MSBuild.exe. You can compile a solution (.sln) or project (.vcxproj) file with MSBuild, and most settings last used inside the IDE are saved in the project file, so there is no need to re-specify most options. If no options are specified the default command is Build; to Clean use /t:Clean, and to clean and then build use /t:Rebuild. You may also wish to change the verbosity with /verbosity:quiet, the levels for verbosity are quiet, minimal, normal, detailed, and diagnostic. "Quiet" just outputs the logo, which with /nologo can be turned off, warnings, and errors. Also, verbosity information is not saved in the project file, so it must be specified on the command line.

So after setting the command prompt up with vcvars32.bat, a line to compile code should look like

msbuild cloudy.sln /t:rebuild /verbosity:quiet 

It should be noted that MSBuild must act on a project or solution file, which means an initial build using MSBuild (without the IDE) would require building a project file by hand.

Using Task Scheduler

To compile Cloudy every night on Windows you will have to use Task Scheduler and probably a few batch files. To open Task Scheduler go to Start>Accessories>System Tools>Task Scheduler. Select the Task Scheduler Library in the left pane and then go to Action>Create Task. Enter a name and if desired a description. There is the option to "Run whether user is logged on or not" which you should set if you ever log out and still want to compile, but requires either admin rights or "Log on as batch job" rights. To add give a user "Log on as batch job" rights requires admin rights and can be found in Control panel -> System and security -> Administrative tools -> Local security policy -> Local policies -> User rights assignment, where the user must be added to the list for "Log on as batch job." Back in task scheduler, Change tab to "Triggers" and select "New..." to create a new trigger then set the conditions you want to compile on. Change tab to "Actions" and select "New..." to create the first action, and make sure "Action:" at the top is set to "Start a Program".

If you do not have another method of updating then the first action should probably be to update. If svn is installed and in PATH, then you can put "svn" in "Program/script:" and "update" in "arguments." If svn is not in PATH, then browse to its location and select the file. Either way, you will also have to set the "Start in:" to the location of the cloudy, such as "C:\cloudy\trunk" (Note: even if there are spaces in this directory, do not use quotes).

Compiling with Task Scheduler and MSBuild requires two actions, which must be in the same task. Before running MSBuild, you must run vcvars32.bat, the location for which is mentioned above. Put the entire file path in quotes into the "Program/script:" field. Then hit "OK" and "New..." again to create the action to run MSbuild. If you want to write the output to a file, then you will need to put the filepath and relevant options in a batch file that might look like

@C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSbuild.exe /t:Rebuild /verbosity:quiet /nologo

then put the name of your solution/project file followed by >CompileLog.txt in "Arguments".

The "@" at the beginning of the line removes the command from the output file, which is optional but makes the output file a little less cluttered.

The number after "\Framework\v" may vary depending upon which versions of Microsoft.NET you have installed. If you have multiple, the highest number should be the most recent version.

To then send this CompileLog.txt to an e-mail account using Task Scheduler's Send e-mail option, in the same task under the action tab select "New..." and in the drop down box select "Send an e-mail." You will need a valid "From" address as well as an SMTP server that will send e-mail without requiring a password. Fill in the "To" and "From" fields with the appropriate e-mail addresses. The "Subject" and "Text" fields are static text, so write something that explains what the e-mail is and use the "Attachment" field to select a file that will be updated, like CompileLog.txt. Finally, in the "SMTP server" field place the hostname of the server that will be sending the e-mail, like smtp.myserver.com.

If you do not want to save the output to a file, put the entire filepath in the "Program/script:" field and options and the solution/project file in the "Arguments" field. In the "Start in:" field put the location of your solution/project file (Note again that the "Start in:" field does not require quotes).


The cloudtests account on thunder

file locations

Cloudy is located inside the folder

C:\Users\cloudtests\Documents\trunk

with each of the subdirectories inside of that. It can also be accessed through the Cloudy Library in Libraries\Cloudy.

The Visual Studio solution file (.sln) is found in

C:\Users\cloudtests\Documents\Visual Studio 2012\Projects\trunk

and from here, the Project file (.vcxproj) that contains the file list and compiler options is in the next "trunk" sub-directory (\Projects\trunk\trunk). The executable is found in the "Debug" sub-directory (\Projects\trunk\Debug).

The batch files used in Task Scheduler are all located in the same folder as cloudy: C:\Users\cloudtests\Documents\trunk.

The output for compiling cloudy, compileLog.txt, is located in the folder with the solution file (C:\Users\cloudtests\Documents\Visual Studio 2012\Projects\trunk).

The outputs for func_test.in and pn_paris.in are in C:\Users\cloudtests\Documents\trunk\tsuite\auto.

The concatenated file sent with the e-mail, overnightHistory.txt, is like the batch files, in the folder with cloudy C:\Users\cloudtests\Documents\trunk.

task scheduler setup

Task Scheduler is setup to trigger the following at 12:00 AM everyday.

  1. Update the local version of cloudy with SVN.
  1. Setup the environment for visual studio.
  1. Clean and build cloudy in quiet mode and save the output to compileLog.txt
  1. Run the two tests func_test and pn_paris
  1. Concatenate the brief output of the tests and the compilation history output to one file overnightHistory.txt
  1. E-mail overnightHistory.txt as a report.

Return to DeveloperPages

Return to main wiki page


Last modified 3 years ago Last modified on 2014-11-17T12:42:20Z