尝试使用 Cygwin 在 Windows 机器上编译 MPICH2。
一点相关资料
- $ uname -> CYGWIN_NT-6.1
- $ gcc --version -> gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) 版权所有 (C) 2004 Free Software Foundation, Inc. 这是免费软件;查看复制条件的来源。没有保修;甚至不考虑适销性或特定用途的适用性。
- MPICH2 版本:1.5
配置似乎已正确完成,但在编译期间我收到以下信息:
**** Making src/misc ....
make --no-print-directory build_lib_bin
make --no-print-directory mpe_debug_objs
make --no-print-directory /home/Daeden/issm/trunk-jpl/externalpackages/mpich2/src/src/mpe2/lib/libmpe_nompi.a
make[7]: `/home/Daeden/issm/trunk-jpl/externalpackages/mpich2/src/src/mpe2/lib/libmpe_nompi.a' is up to date.
make --no-print-directory /home/Daeden/issm/trunk-jpl/externalpackages/mpich2/src/src/mpe2/lib/libmpe.a
gcc -I/home/Daeden/issm/trunk-jpl/externalpackages/mpich2/src/src/include -I/home/Daeden/issm/trunk-jpl/externalpackages/mpich2/src/ src/include -I.. -I../include -I../../.. -I../../../include -o dbxerr.po -c dbxerr.c
dbxerr.c: In function `MPE_DefaultHandler':
dbxerr.c:429: error: parse error before '{' token
dbxerr.c:432: error: argument "sig" doesn't match prototype
dbxerr.c:407: error: prototype declaration
dbxerr.c:461: warning: passing arg 2 of `signal' from incompatible pointer type
dbxerr.c:463: warning: passing arg 2 of `signal' from incompatible pointer type
dbxerr.c:465: warning: passing arg 2 of `signal' from incompatible pointer type
dbxerr.c:467: warning: passing arg 2 of `signal' from incompatible pointer type
dbxerr.c:469: warning: passing arg 2 of `signal' from incompatible pointer type
dbxerr.c:473: warning: passing arg 2 of `signal' from incompatible pointer type
Makefile:82: recipe for target `dbxerr.po' failed
make[7]: *** [dbxerr.po] Error 1
Makefile:111: recipe for target `default' failed
make[6]: *** [default] Error 2
Makefile:43: recipe for target `build_lib_bin' failed
make[5]: *** [build_lib_bin] Error 2
Makefile:26: recipe for target `all' failed make[4]: *** [all] Error 2
检查“dbxerr.c”我发现:
#if defined(HAVE_SIGHANDLER_T)
#define SIG_HANDLER_PROTOTYPE sighandler_t
void MPE_DefaultHandler ( SIG_HANDLER_PROTOTYPE );
void MPE_DefaultHandler( sig )
int sig
#elif defined(MPI_sun4)
#define SIG_HANDLER_PROTOTYPE int, int, struct sigcontext *, char *
void MPE_DefaultHandler ( SIG_HANDLER_PROTOTYPE );
void MPE_DefaultHandler( sig, code, scp, addr )
int sig, code;
struct sigcontext *scp;
char *addr;
#elif defined(MPI_IRIX)
#define SIG_HANDLER_PROTOTYPE int, int, struct sigcontext *
void MPE_DefaultHandler ( SIG_HANDLER_PROTOTYPE );
void MPE_DefaultHandler( sig, code, scp )
int sig, code;
struct sigcontext *scp;
#else
/* The default Posix definition has a single int */
#define SIG_HANDLER_PROTOTYPE int
void MPE_DefaultHandler ( SIG_HANDLER_PROTOTYPE );
void MPE_DefaultHandler( int sig )
#endif
{
static char buf[128];
signal( sig, SIG_DFL );
if (sig >= 0 && sig <= 20)
sprintf( buf, "Caught signal %s", SIGNAME[sig] );
else
strcpy( buf, "Caught signal " );
fprintf( stderr, "%s\n", buf );
MPE_Start_debugger( );
}
通过检查'config.log'我发现:
$ find ./ -name 'config.log' | xargs grep 'HAVE_SIGHANDLER'
./src/mpe2/src/misc/config.log:| #define HAVE_SIGHANDLER_T 1
./src/mpe2/src/misc/config.log:#define HAVE_SIGHANDLER_T 1
这证实了:
void MPE_DefaultHandler ( SIG_HANDLER_PROTOTYPE );
void MPE_DefaultHandler( sig )
int sig
正被 CPP 使用。
我发现'SIG_HANDLER_PROTOTYPE'被定义为:
$ find ./ -name '*.c' | xargs grep 'SIG_HANDLER_PRO'
./src/mpe2/src/misc/src/dbxerr.c:#define SIG_HANDLER_PROTOTYPE sighandler_t
'sighandler_t' 在 '/usr/include/signal.h' 中定义为:
typedef _sig_func_ptr sighandler_t; /* glibc naming */
最后,'_sig_func_ptr' 定义为:
typedef void (*_sig_func_ptr)(int);
这是就我自己的研究而言,我似乎无法将各个部分组合在一起。我不明白为什么会有原型不匹配。我将继续尝试自己解决此问题,但我们将不胜感激!
提前致谢!
更新:
我正在重新检查“make”的输出,我认为我犯了一个错误。我认为问题出在声明上:
void MPE_DefaultHandler ( SIG_HANDLER_PROTOTYPE );
但是,问题似乎与定义有关:
void MPE_DefaultHandler( sig )
'sig' 似乎是一个 int 类型,但我不明白 'SIG_HANDLER_PROTOTYPE' 是什么类型。有人可以解释一下吗:
typedef void (*_sig_func_ptr)(int);