|
This section takes you through the steps of compiling and linking in C. You can use csWMPI
with any C compiler compatible with Microsoft C Compiler generated .lib files.
Currently Microsoft Visual C++ and Intel C++ Compiler are supported.
In order to do cross compilation, e.g. compiling in Windows 32-bit for a 64-bit
platform, all csWMPI distributions for Windows contain lib files
for all 3 windows platforms. In the base [install dir] directory, one can find the distribution
platform lib files in [install dir]\lib directory.
csWMPI lib files for each platform can be found in the following subdirs:
[install dir]\libi32 - for 32-bit systems
[install dir]\libx86_64 - for 64-bit Extended Systems
Include files are common for all platforms and can be found in [install dir]\include.
To do cross-compilation, start the development environment for the target platform and use
the platform specific lib directory instead of the default one.
This section shows you the basic options that you have to set in order
to use csWMPI in a C project. The way to set these options is dependent on
your compiler and you must look how to set them in the Compiler's Documentation.
- Set include path: [install dir]\include
- Link with the library: csWMPI.lib
Step 1: Include Path
In order to use csWMPI you will need to include the file mpi.h. This
include file is found in the directory [install dir]\include and can be
referenced in a portable manner by using the environment variable
MPI_ROOT. To use environment variables, please make sure that your compiler expands them
when setting the Include Path.
Example 1:
Using a compiler that expands environment variables in options, you would specify it as:
$(MPI2_ROOT)\include
Example 2:
Using a compiler that does not expand environment variables in options and having csWMPI installed in the
default directory, you would specify it as:
C:\Program Files\csWMPI\include
Step 2: Link Settings
In order to use csWMPI you will need to link with csWMPI.lib.
This file can be found in the directory [install dir]\lib and can be
referenced in a portable manner by using the environment variable
MPI_ROOT. To use environment variables, please make sure that your compiler expands them
when setting the Lib Path options.
Example 1:
Using a compiler that expands environment variables in options, you would specify it as:
$(MPI2_ROOT)\lib\csWMPI.lib
Example 2:
Using a compiler that does not expand environment variables in options and having csWMPI installed in the
default directory, you would specify it as:
C:\Program Files\csWMPI\lib\csWMPI.lib
This section shows you how to configure your Microsoft Visual C++ 7 projects
to use csWMPI in C:
- Include the file: mpi.h
- Set code generation to "Multithreaded DLL"
- Link with the library: csWMPI.lib
SPECIAL NOTE FOR x86_64 SYSTEMS: Make sure that Visual C++ is configured to use the
compiler for 64-bit extended systems and in case the version installed is for other platform,
use the platform specific lib dir, located in $(MPI2_ROOT)\x86_64\lib.
Step 1: Include File
In order to use csWMPI you will need to include the file mpi.h. This
include file is found in the directory [install dir]\include and can be
referenced in a portable manner by using the environment variable
MPI_ROOT.
Example:
Go to "Project | Properties", open the "C/C++" folder and choose category "General" add $(MPI_ROOT)\include to "Additional include directories".
Step 2: Code Generation
To avoid link warnings and errors it is necessary to configure your csWMPI application to use "Multithreaded
DLL" run-time libraries. Go to "Project | Properties", open the "C/C++" folder and choose category
"Code Generation". Now choose "Multithreaded DLL" in the "Runtime Library" property.
Step 3: Link Settings
In order to use csWMPI it is necessary that your project link with the library
csWMPI.lib. To configure this go to "Project | Properties", open the "Linker" folder, choose
category "General" and add the path $(MPI_ROOT)\lib to the "Additional Library Directories".
From the "Linker" folder, select the "Input" section and add the csWMPI.lib to the
Additional Dependencies.
This section describes how to use csWMPI with the Intel C++ Compiler under the command line.
If you are using the Intel C++ Compiler integrated with Visual Studio, please refer to
the Microsoft Visual C++ section.
After starting the Build Environment for the target platform, to use csWMPI you need to follow these steps:
- Set include path: [install dir]\include
- Link with the library: csWMPI.lib
Step 1: Include Path
In order to use csWMPI you will need to include the file mpi.h. This
include file is found in the directory [install dir]\include and can be
referenced in a portable manner by using the environment variable
MPI_ROOT.
For the Intel C++ Compiler you have to specify the option:
/I "%MPI_ROOT%\include"
Example for I32 platform:
To compile hello_world.c and produce a compiled object, hello_world.obj, run the following command:
icl /I "%MPI_ROOT%\include" /c hello_world.c
Step 2: Link Settings
In order to use csWMPI you will need to link with csWMPI.lib.
This file can be found in the directory [install dir]\lib and can be
referenced in a portable manner by using the environment variable
MPI_ROOT.
For the Intel C++ Compiler you have to include the following options:
/libpath:"%MPI_ROOT%\lib" csWMPI2.lib
Example:
To link the previous compiled object, hello_world.obj, and produce the final executable, one can
execute the following command:
xilink /out:hello_world.exe /libpath:"%MPI_ROOT%\lib" csWMPI2.lib hello_world.obj
|