C guide - Windows

This section takes you through the steps of compiling and linking in C. You can use csWMPI II with any C compiler compatible with Microsoft C Compiler generated .lib files. Currently Microsoft Visual C++ and Intel C++ Compiler are supported.


Cross Compilation

In order to do cross compilation, e.g. compiling in Windows 32-bit for a 64-bit platform, all csWMPI II 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 II 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.


    Generic C Compiler

    This section shows you the basic options that you have to set in order to use csWMPI II 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.

    1. Set include path: [install dir]\include
    2. Link with the library: csWMPI II2.lib

    Step 1: Include Path
    In order to use csWMPI II 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 MPI2_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 II installed in the default directory, you would specify it as:
    C:\Program Files\csWMPI II\include

    Step 2: Link Settings
    In order to use csWMPI II you will need to link with csWMPI II2.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 MPI2_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 II2.lib

    Example 2:
    Using a compiler that does not expand environment variables in options and having csWMPI II installed in the default directory, you would specify it as:
    C:\Program Files\csWMPI II\lib\csWMPI II2.lib


    Microsoft Visual C++

    This section shows you how to configure your Microsoft Visual C++ 7 projects to use csWMPI II in C:

    1. Include the file: mpi.h
    2. Set code generation to "Multithreaded DLL"
    3. Link with the library: csWMPI II2.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 II 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 MPI2_ROOT.

    Example:
    Go to "Project | Properties", open the "C/C++" folder and choose category "General" add $(MPI2_ROOT)\include to "Additional include directories".



    Step 2: Code Generation
    To avoid link warnings and errors it is necessary to configure your csWMPI II 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 II it is necessary that your project link with the library csWMPI II2.lib. To configure this go to "Project | Properties", open the "Linker" folder, choose category "General" and add the path $(MPI2_ROOT)\lib to the "Additional Library Directories".

    From the "Linker" folder, select the "Input" section and add the csWMPI II2.lib to the Additional Dependencies.



    Intel C++ Compiler

    This section describes how to use csWMPI II 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 II you need to follow these steps:

    1. Set include path: [install dir]\include
    2. Link with the library: csWMPI II2.lib

    Step 1: Include Path
    In order to use csWMPI II 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 MPI2_ROOT.
    For the Intel C++ Compiler you have to specify the option:

    /I "%MPI2_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 "%MPI2_ROOT%\include" /c hello_world.c

    Step 2: Link Settings
    In order to use csWMPI II you will need to link with csWMPI II2.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 MPI2_ROOT.
    For the Intel C++ Compiler you have to include the following options:

    /libpath:"%MPI2_ROOT%\lib" csWMPI II2.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:"%MPI2_ROOT%\lib" csWMPI II2.lib hello_world.obj




    © 2009 Critical Software SA. All trademarks and copyrights on this page are owned by their respective owners.
    csWMPI II™, csWMPI II™ and PatentMPI™ are trademarks of Critical Software SA. All Rights Reserved.