2008年12月23日

error of unable to load c2.dll

Fatal error LNK1171: unable to load c2.dll

We had an interesting problem arise where linking a Release mode static library written in C with a Fortran application using the Premier Partner edition of Visual Studio that ships with Intel Visual FORTRAN 10 would die at the linking stage. This happened late in the game as the debug mode builds of the C library did not exhibit this error. To make matters worse, if users had any other version of Visual Studio with just the Intel Visual FORTRAN Compiler Integration installed, no such problems arose.

Our first step was to install the Platform SDK: no joy. The second step was to manually copy the DLL's required (there are actually 3 DLL's you need) from a working install to the non-working install: success!

So, what could possibly be the problem here?

No amount of searching could turn up the issue, so a ticket was opened with Intel's Premier Support. Well, we should have done this from the beginning because it appears that the compiler writers themselves know a lot about the compiler toolchain; fancy that. The (relevant) response from Intel:
c2.dll is used by the Microsoft Visual C++ compiler to perform whole-program optimization. Might it be that this "release" C library was compiled with that option? If so, you will require Visual C++ to be installed in order to build using that library.

My advice is that if you know you will be linking a C library on a system with only Visual Studio Premier Partner Edition installed that you be sure that Whole Program Optimization is disabled, as otherwise Fortran programmers will not be able to use it.
Sure enough, disabling Whole Program Optimization on the Release mode builds of the C static library solved all of our issues.Fatal error LNK1171: unable to load c2.dll
We had an interesting problem arise where linking a Release mode static library written in C with a Fortran application using the Premier Partner edition of Visual Studio that ships with Intel Visual FORTRAN 10 would die at the linking stage. This happened late in the game as the debug mode builds of the C library did not exhibit this error. To make matters worse, if users had any other version of Visual Studio with just the Intel Visual FORTRAN Compiler Integration installed, no such problems arose.

Our first step was to install the Platform SDK: no joy. The second step was to manually copy the DLL's required (there are actually 3 DLL's you need) from a working install to the non-working install: success!

So, what could possibly be the problem here?

No amount of searching could turn up the issue, so a ticket was opened with Intel's Premier Support. Well, we should have done this from the beginning because it appears that the compiler writers themselves know a lot about the compiler toolchain; fancy that. The (relevant) response from Intel:
c2.dll is used by the Microsoft Visual C++ compiler to perform whole-program optimization. Might it be that this "release" C library was compiled with that option? If so, you will require Visual C++ to be installed in order to build using that library.

My advice is that if you know you will be linking a C library on a system with only Visual Studio Premier Partner Edition installed that you be sure that Whole Program Optimization is disabled, as otherwise Fortran programmers will not be able to use it.
Sure enough, disabling Whole Program Optimization on the Release mode builds of the C static library solved all of our issues.

2008年12月21日

compile PPM library

1. Introduction 
This article is focus on the compile the PPM library on widows, using Intel Fortran compiler.
The acronym PPM stands for Parallel Particle Mesh library. PPM is a software layer between the Message Passing Interface (MPI) and codes for simulations of physical systems using hybrid particle-mesh methods. The library is developed based on a unifying formulation for the simulations of discrete and continuous systems using particles. In this formulation the well known grid-free character of the method is relaxed by the introduction of a mesh for the reinitialization of the particles, the computation of the field equations, and the discretization of differential operators.

2.Libraries used in PPM library.
The PPM library used four  libraries:MPI, fftw, metis,vizing. Before compile PPM library, the above four libraries needed to be compiled. 
3.1 compile MPI library:
The MPICH2 is used as MPI library, which can be downloaded from the website.http://www.mcs.anl.gov/research/projects/mpich2/ install the MPICH then the MPI library is installed.
3.2 metis library:
metis library is the demoain decomposssion library. the source file can be download at http://glaros.dtc.umn.edu/gkhome/metis/metis/download  The metis install introduction is based on linux, for windows. The Microsoft visual studio is used to compile the metis library. 
(1) Create a static library in MS 
(2)  " #define __VC__" at the first line of "metis.h". Then the libaray will use rand instead of srand48 and drand48 function.
(3) comment the word "extern "c" " in  file "balance.c", this is becuase "extern "c" " is the keyword in c++, there is no "extern "c"" in c standard. 
 (4) make sure that the run time library is "multi threaded", by default the MS us " multi threaded DLL"
3.2 vizing library:
the vizing library is called by PPM library for neighboring communication. download the vizing library. and create the static library as the metis library. 
 (1) make sure that the run time library is "multi threaded", by default the MS us " multi threaded DLL"