tRNALab

 

An installation file of free Visual Studio Community 2022 can be downloaded here. After its installation, open Visual Studio, select Create a new project C++ Console App, push Next, and select Project name, e.g., hello_world_simplest, and Location. Then you can: 1) run a default Hello World program provided by Visual Studio pushing a green arrow, 2) copy the code of my project hello_world_simplest (PDF) to hello_world_simplest.cpp and run it, or 3) download my project hello_world_simplest (Visual_Studio), unzip it, open Visual Studio, push Open a project or solution, locate and double click hello_world_simplest.sln, unfold Source Files in Solution Explorer on the left, double click on hello_world_simplest.cpp in Solution Explorer, and push the button with a green arrow. Alternatively, you can select Build Build Solution or push F7 to compile the program. If there were errors or warnings in your program, they would be listed in Errors resp. Warnings at the bottom of your IDE. You can double click on them to locate their positions in your program or double click on a code in front of them to see a help. If you get into problems during debugging, don't forget to step through your program line by line and observe the current values of your program's variables. When you correct all errors, you can compile and run the program.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Visual Studio Community 2022

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Hello world simplest runs only in Visual Studio. If you wanted to make it running under various operating systems, it would be sufficient to use preprocessor directives as in the next sample.

 

hello_world_basics (Visual Studio, Linux, PDF):
You can compile this code in Linux by
      g++ hello_world_basics.cpp -o hello_world_basics
and launch it by
      ./hello_world_basics

 

Hereinafter, the most important samples are emphasized by !!! and the most demanding ones by *, ** or ***. The samples indicated by + only comprise programs that can appear to be useful sometime in the future: almost all of them will be skipped during the lecture.

 

hello_world_classes: Because the sample 7A consists of 3 files - hello_world_classes.cpp, hello_class.cpp, and hello_class.h - you have to compile it in Linux by
      g++ hello_class.cpp hello_world_classes.cpp -o hello_world_classes
and launch it by
      ./hello_world_classes


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

MS MPI

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Instalation files: The installation files of MS MPI can be downloaded here. It is necessary to restart your computer after the installation of MS MPI. Then you can test its functionality in a Command Promt. Write (Settings for Visual Studio):

 

C:\Windows\System32> set MSMPI

 

If the echo of the system is

 

MSMPI_BENCHMARKS=C:\Program Files\Microsoft MPI\Benchmarks\
MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\
MSMPI_INC=C:\Program Files (x86)\Microsoft SDKs\MPI\Include\
MSMPI_LIB32=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x86\
MSMPI_LIB64=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\

 

C:\Windows\System32>

 

it means that your MS MPI has been installed successfully. Then:

 

1. Open Visual Studio, click on Create a new project, write C++ instead of Search for templates, select Console App, and push Next. Let Project name is, e.g., myMPI. Select Location and push Create.
2. Do not forget to specify Solution Platform, e.g., x64 in a selector list of a small upper left window.
3. In the main menu, open Project myMPI Properties C/C++. In the upper central edit memo named Platform, set your operating system, e.g., Active(x64), and, depending on it, add $(MSMPI_INC);$(MSMPI_INC)\x64 or $(MSMPI_INC);$(MSMPI_INC)\x86 into Additional Include Directories.
4. Open Project myMPI Properties Linker Input and add msmpi.lib into Additional Dependencies.
5. Open Project myMPI Properties Linker General and, depending on your operating system, add $(MSMPI_LIB64) or $(MSMPI_LIB32) into Additional Library Directories.

 

Afterwards, you can copy the code from a PDF hyperlink of 1A_Hello_world.cpp to your myMPI. Try compiling it. If the compiler has announced errors for mpi.h, MPI_Init, etc., your MPI has not started to collaborate with Visual Studio yet, and so try to wait to the next day and repeat the compilation.

 

MPI_Routines (taken from www.mpich.org/static/docs/v3.2).
MPI_Constants (taken from www.mpich.org/static/docs/latest/www3/Constants.html).

 

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------