[MPICH] compilation under VS2005 - get wspiapi.h out of extern "C" block

Jayesh Krishna jayesh at mcs.anl.gov
Wed Nov 1 13:10:39 CST 2006


Hi,
 Another solution (which is easier to manage) would be to just exclude the
C++ header file from the extern "C" {} block using the extern "C++" {}
block. You might want to modify the code in mpidu_socki.h as below,
 
-------------------------------------------------------------
/* ws2tcpip.h is a C++ header file */
#ifdef __cplusplus
    extern "C++" {
#endif
        #include <ws2tcpip.h>
#ifdef __cplusplus
    }
#endif
-------------------------------------------------------------
 
Regards,

----------------------------------
 Jayesh Krishna
 Argonne National Laboratory
 Mathematics and Computer Science
 Email: jayesh at mcs.anl.gov
---------------------------------- 

 

  _____  

From: owner-mpich-discuss at mcs.anl.gov
[mailto:owner-mpich-discuss at mcs.anl.gov] On Behalf Of devteam
Sent: Tuesday, October 17, 2006 8:44 AM
To: Jayesh Krishna; mpich-discuss at mcs.anl.gov
Cc: mpich2-maint at mcs.anl.gov
Subject: Re: [MPICH] compilation under VS2005 - get wspiapi.h out of extern
"C" block


Hi,
 
I finally almost got it.
I used mpich2.1.0.2p1 (there is no --vs05 option for winconfigure in the
mpich2.1.0.4p1 version).
 
I had to do several things:
In smpd_util project:
    * Add smpd_job.c to the project 
    * add MPICH_IGNORE_CXX_SEEK compilation directive
 
In mpidu_sock.h:
add CPLUSPLUS_END before #include "mpidu_socki.h and CPLUSPLUS_BEGIN just
after
 
In mpiexec project (same in smpd project) link also with:
    * activeds.lib and netapi32.lib
 
Then mpiexec compiles and link and there remains undefined symbols related
to activeDir stuff. 
 
In order to generate mpiexec.exe I had to comment out references to
IID_IDirectoryObject, IID_IADsContainer,IID_IDirectorySearch in smpd_ad.cpp
(but not in smpd_adreg.cpp).
 
Andres

----- Original Message ----- 
From: Jayesh  <mailto:jayesh at mcs.anl.gov> Krishna 
To: mpich-discuss at mcs.anl.gov 
Cc: mpich2-maint at mcs.anl.gov 
Sent: Monday, October 16, 2006 8:34 PM
Subject: FW: [MPICH] compilation under VS2005 - get wspiapi.h out of extern
"C" block

Hi,
 In VS 2005 there are C++ templates in some of the header files (VS 2003 did
not have them). So these header files should be considered as C++ header
files rather than C header files and one has to make sure that these C++
header files are outside the extern "C" {} blocks in the code.
 One such C++ header file is <wspiapi.h>. If you make sure that this header
file is not included in an extern "C" {} block you should be able to get
past this compilation error (Please note that this header file may be
included by some other header files in an extern "C" block. To know the list
of header files included by your source code and the order in which they are
included enable "show includes" in Visual studio.).
 This code works for Visual Studio 2003 and we will be changing the code to
make it compatible with VS 2005 in our next release.
 Please let us know if this works for you.
 
Regards,

----------------------------------
 Jayesh Krishna
 Argonne National Laboratory
 Mathematics and Computer Science
 Email: jayesh at mcs.anl.gov
---------------------------------- 

 

  _____  

From: owner-mpich-discuss at mcs.anl.gov
[mailto:owner-mpich-discuss at mcs.anl.gov] On Behalf Of devteam
Sent: Monday, October 16, 2006 3:23 AM
To: mpich-discuss at mcs.anl.gov
Subject: [MPICH] compilation under VS2005


Hello everyone,
 
We've trying to compile mpich2 under VS2005, with no success yet... here is
the error message.
 
Any suggestions on what's going wrong ?
 
Thank you,
 
Andres
 
 
in wsiapi.h
 


#if !defined(_WSPIAPI_COUNTOF)
#if !defined(__cplusplus)
#define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#else
template <typename __CountofType, size_t _N>
char (&__wspiapi_countof_helper(__CountofType (&_Array)[_N]))[_N];
#define _WSPIAPI_COUNTOF(_Array) sizeof(__wspiapi_countof_helper(_Array))
#endif
#endif
 
error message: 
 
1>------ Build started: Project: smpd_util, Configuration: Debug Win32
------
1>Compiling...
1>smpd_adreg.cpp
1>c:\program files\microsoft visual studio
8\vc\platformsdk\include\wspiapi.h(44) : error C2894: templates cannot be
declared to have 'C' linkage
1>Build log was saved at
"file://d:\DEVELOPPEMENTS\MPICH2\Argonne\mpich2-1.0.2p1\mpich2-1.0.2p1\src\p
m\smpd\smpd_utilDebug\BuildLog.htm"
1>smpd_util - 1 error(s), 0 warning(s)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20061101/b949a7de/attachment.htm>


More information about the mpich-discuss mailing list