Build Petsc DLL's with Visual Studio C++ 2003 compiler

Thuc Bui bui at
Fri Oct 3 12:15:02 CDT 2008

Thank you Satish and Chetan very much for your answers. I will try out
Chetan's project/solution files this weekend. Before doing so, I will need
to re-run only once per Chetan's instruction then copy and
rename the build directories. I will set the configuration option
--with-shared=0. If this is incorrect, please let me know.


-----Original Message-----
From: owner-petsc-users at [mailto:owner-petsc-users at]
On Behalf Of Chetan Jhurani
Sent: Thursday, October 02, 2008 11:21 PM
To: petsc-users at
Subject: RE: Build Petsc DLL's with Visual Studio C++ 2003 compiler

On Thu, 2 Oct 2008, Satish Balay wrote:
> On Thu, 2 Oct 2008, Thuc Bui wrote:
> > I attempt to build Petsc DLL libraries with using first
> > the option --with-shared=1, which is ignored as indicated in
> > and with --with-dynamic=1, which the script crashes.
> > 
> > Is it possible to build Petsc DLL's? Does any one know how to do this? I
> > would like to reduce the size of my executables since I have several
> > Petsc, and each of them is now huge comparing with that use the "old"
> > Sparskit solver.
> Sorry - currently we don't have a mechanism to build dlls on
> windows. So the above options [shared and dynamic] don't work on
> windows.

I have created a set of visual studio project/solution files.  They've been
tried with petsc-2.3.2-p7.  There are 4 configurations -- Debug, Release,
DebugDLL, and ReleaseDLL.  The first two create a static lib, and the last
two create a DLL (one output file per config).

This results in a petsc.dll of size 3 MB in release mode. Debug mode is 8.5

You can get them here -

Place the files in petsc-2.3.2-p7/src directory. Run petsc config script,
rename the $config directories in bmake directory to appropriate name
Release, DebugDLL, ReleaseDLL).  You'll have to run petsc configure ONCE and
copy directories.  Change PETSC_ARCH_NAME and PETSC_NAME in petscconf.h
in each directory. Preprocessor macros like PETSC_DLL_EXPORT are defined
in the vcproj file.


- I'm sure I've missed some steps that I no longer remember.
- Not all the files in petsc/src are compiled. Most are.
- The output (objs, libs, dlls) go into non-standard directories, so change
- Some env variables, like $(MPI_DIR), are used in include/link paths.
- blas.lib and lapack.lib are assumed to exist in link path.


More information about the petsc-users mailing list