我最近尝试在Windows 7 / 64bit上安装MPICH2和gcc编译器。我安装了一切没有任何问题,我希望它通过NotePad ++运行代码,我包括所有的东西,所以我可以编译。但是当我尝试编译代码时,我收到了这个错误:
CD: C:\MinGW\MPICH2\examples
Current directory: C:\MinGW\MPICH2\examples
ENV_SET: MPI_HOME = /MinGW/MPICH2
$(SYS.MPI_HOME) = /MinGW/MPICH2
gcc -Wall -I/MinGW/MPICH2/include -c -std=c99 -lm icpi.c
Process started >>>
<<< Process finished. (Exit code 0)
gcc icpi.o -L/MinGW/MPICH2/lib -lmpi -lfmpich2g -o icpi
Process started >>>
icpi.o:icpi.c:(.text+0xc7): undefined reference to `MPI_Init'
icpi.o:icpi.c:(.text+0xde): undefined reference to `MPI_Comm_size'
icpi.o:icpi.c:(.text+0xf5): undefined reference to `MPI_Comm_rank'
icpi.o:icpi.c:(.text+0x10c): undefined reference to `MPI_Get_processor_name'
icpi.o:icpi.c:(.text+0x188): undefined reference to `MPI_Wtime'
icpi.o:icpi.c:(.text+0x1be): undefined reference to `MPI_Bcast'
icpi.o:icpi.c:(.text+0x2d4): undefined reference to `MPI_Reduce'
icpi.o:icpi.c:(.text+0x31b): undefined reference to `MPI_Wtime'
icpi.o:icpi.c:(.text+0x36d): undefined reference to `MPI_Finalize'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: icpi.o: bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
这是我的执行命令:
cd $(CURRENT_DIRECTORY)
ENV_SET MPI_HOME = /MinGW/MPICH2
gcc -Wall -I$(SYS.MPI_HOME)/include -c -std=c99 -lm $(FILE_NAME)
gcc $(NAME_PART).o -L$(SYS.MPI_HOME)/lib -lmpi -lfmpich2g -o $(NAME_PART)
mpiexec -np 10 $(CURRENT_DIRECTORY)\$(NAME_PART).exe