[petsc-users] Petsc compilation with -MDd using visual studio c++ 2008

Satish Balay balay at mcs.anl.gov
Mon Aug 11 11:44:41 CDT 2014


Can you try the attached patch?

patch -Np1  < win-f2cblas.patch

Satish

On Mon, 11 Aug 2014, Mengda Wu wrote:

> Hi Satish,
> 
>     I think this problem happens in the latest 3.5.1 version. On windows 7
> with VS2012, I configured with (under Cygwin):
> 
>    ./config/configure.py --with-cc='cl' --with-fc=0  --with-cxx='cl'
> --with-mpi=0 --with-debugging=1
> --download-f2cblaslapack=/cygdrive/d/Library/PETSc/download/f2cblaslapack-3.4.2.q1.tar.gz
> --with-sowing=0 --with-c2html=0 -CFLAGS='-MDd -wd4996' -CXXFLAGS='-MDd
> -wd4996'
> 
>     After configure, in
> petsc-3.5.1\arch-mswin-c-debug\externalpackages\f2cblaslapack-3.4.2.q1
>     CC = /cygdrive/d/Library/PETSc/petsc-3.5.1/bin/win32fe/win32fe cl
>     COPTFLAGS  = -MDd -wd4996 -Z7
>     CNOOPT =    -MD
> 
>     So CNOOPT does not get correct "-MDd", which causes the VC dll mismatch
> after compilation of Petsc debug. There was no problem with  petsc-3.4.3. I
> am trying to upgrade to 3.5.1 and the problem came out. Could you please
> take a look?
> 
> Thanks,
> Mengda
> 
> On Sun, Dec 18, 2011 at 2:14 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> 
> > On Sun, 18 Dec 2011, Mengda Wu wrote:
> >
> > > Hi all,
> > >
> > >    I am trying to compile with a debug version of Petsc with -MDd options
> > > using visual studio c++ 2008. The following options are used.
> > >
> > > ./config/configure.py --with-cc='cl' --with-fc=0  --with-cxx='cl'
> > > --with-mpi=0 --with-debugging=1
> > > --download-f2cblaslapack=/path/to/f2cblaslapack-3.1.1.q.tar.gz
> > > -CFLAGS='-MDd -wd4996' -CXXFLAGS='-MDd -wd4996'
> > >
> > > But it seems that f2cblaslapack does not recognize "-MDd" completely.
> > Some
> > > files are still compiled with '-MD' instead of "-MDd". This will lead to
> > a
> > > problem that not all libraries are linked with the same MS C library. I
> > > think it may be caused by the variable "CNOOPT" is not set properly in
> > > config/BuildSystem/config/packages/f2cblaslapack.py and
> > > config/BuildSystem/config/packages/BlasLapack.py. Only '-MD' is present
> > > there. See
> > >
> > >   def getWindowsNonOptFlags(self,cflags):
> > >     for flag in ['-MT','-MTd','-MD','-threads']:
> > >       if cflags.find(flag) >=0: return flag
> > >     return ''
> > >
> > > If I substitute '-MD' with '-MDd', then it works. But this will lead to
> > > problem when '-MD' is preferred.
> > >
> >
> > You can just add 'MDd' to that list.
> >
> > i.e
> >
> >     for flag in ['-MT','-MTd','-MD','-MDd','-threads']:
> >
> > Will add this for the next patch update to petsc-3.2
> >
> > Satish
> >
> > > I am wondering if anyone can fix this problem.
> > >
> > > Thanks,
> > > Mengda
> > >
> >
> >
> 
-------------- next part --------------
diff --git a/config/BuildSystem/config/package.py b/config/BuildSystem/config/package.py
index 281450f..66ac42e 100644
--- a/config/BuildSystem/config/package.py
+++ b/config/BuildSystem/config/package.py
@@ -141,9 +141,11 @@ class Package(config.base.Configure):
     return ''
 
   def getWindowsNonOptFlags(self,cflags):
-    for flag in ['-MT','-MTd','-MD','-MDd','-threads']:
-      if cflags.find(flag) >=0: return flag
-    return ''
+    outflags = []
+    for flag in cflags.split():
+      if flag in ['-MT','-MTd','-MD','-MDd','-threads']:
+        outflags.append(flag)
+    return ' '.join(outflags)
 
   def getDefaultLanguage(self):
     '''The language in which to run tests'''


More information about the petsc-users mailing list