Link 在 Cygwin 上使用 MPI 编译器时出错?

Link errơr using MPI compiler on Cygwin?

我尝试使用 Cygwin 构建 MPI 程序。我有以下错误。我是 Cygwin 的新用户,我正在努力学习它。对不起,如果我不明白什么。

我正在尝试使用 Xbraid 包并按照用户手册的说明进行操作,但出现此错误。

有人可以帮忙吗?

Building ex-01-pp ...
mpiCC -g -Wall -I../braid ex-01-pp.cpp -o ex-01-pp ../braid/libbraid.a -lm
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.data+0x0): undefined reference to `__gxx_personality_seh0'
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.xdata+0xc): undefined reference to `__gxx_personality_seh0'
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.xdata+0xc): relocation truncated to fit: rva32 against undefined symbol `__gxx_personality_seh0'
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.xdata+0x2c): undefined reference to `__gxx_personality_seh0'
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.xdata+0x2c): relocation truncated to fit: rva32 against undefined symbol `__gxx_personality_seh0'
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.xdata+0x84): undefined reference to `__gxx_personality_seh0'
...
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.rdata$_ZTI11BraidVector[_ZTI11BraidVector]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/tmp/ccgmW1LF.o:ex-01-pp.cpp:(.rdata$_ZTI8BraidApp[_ZTI8BraidApp]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/usr/lib/libcygwin.a(_cygwin_crt0_common.o):/usr/src/debug/cygwin-3.0.7-1/winsup/cygwin/lib/_cygwin_crt0_common.cc:78: undefined reference to `operator new(unsigned long)'
collect2: σφάλμα: η ld επέστρεψε κατάσταση εξόδου 1
make[1]: *** [Makefile:94: ex-01-pp] Error 1
make[1]: Leaving directory '/cygdrive/c/users/spyros/Desktop/xbraid-master/examples'
make: *** [Makefile:37: examples] Error 2

make 文件是:

BRAID_DIR=../braid
include ../makefile.inc


##################################################################
# Build exmaples 
##################################################################

HYPRE_DIR = ../../hypre/src/hypre
HYPRE_FLAGS = -I$(HYPRE_DIR)/include
HYPRE_LIB = -L$(HYPRE_DIR)/lib -lHYPRE
HYPRE_LIB_FILE = $(HYPRE_DIR)/lib/libHYPRE.a

MFEM_DIR = ../../mfem
MFEM_CONFIG_MK = $(MFEM_DIR)/config/config.mk
MFEM_LIB_FILE = mfem_is_not_built
-include $(MFEM_CONFIG_MK)

BRAID_FLAGS = -I$(BRAID_DIR)
BRAID_LIB_FILE = $(BRAID_DIR)/libbraid.a

C_NOHYPRE = ex-01 ex-01-adjoint ex-01-optimization ex-01-refinement ex-01-expanded ex-01-expanded-bdf2 ex-02 ex-04 ex-04-serial
CPP_NOHYPRE = ex-01-pp 
F_NOHYPRE = ex-01-expanded-f
C_EXAMPLES = ex-03 ex-03-serial
# Note: .cpp examples will be linked with mfem
#CXX_EXAMPLES = ex-04

.PHONY: all clean cleanout

.SUFFIXES:
.SUFFIXES: .c .cpp

# put this rule first so it becomes the default
all: $(C_NOHYPRE) $(CPP_NOHYPRE) $(C_EXAMPLES) $(CXX_EXAMPLES)

# Rule for building ex-01
ex-01: ex-01.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-01-adjoint
ex-01-adjoint: ex-01-adjoint.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-01-optimization
ex-01-optimization: ex-01-optimization.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)


# Rule for building ex-01-refinement
ex-01-refinement: ex-01-refinement.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-01-expanded
ex-01-expanded: ex-01-expanded.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-01-pp
ex-01-pp: ex-01-pp.cpp $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICXX) $(CXXFLAGS) $(BRAID_FLAGS) $(@).cpp -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-01-expanded-f
ex-01-expanded-f: ex-01-expanded-f.f90 $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPIF90) $(FORTFLAGS) -Wno-unused-dummy-argument -Wno-uninitialized $(@).f90 -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-01-expanded-bdf2
ex-01-expanded-bdf2: ex-01-expanded-bdf2.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-02
ex-02: ex-02.c $(BRAID_LIB_FILE) ex-02-lib.c
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-02-serial
ex-02-serial: ex-02-serial.c $(BRAID_LIB_FILE) ex-02-lib.c
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-03
ex-03: ex-03.c $(BRAID_LIB_FILE) $(HYPRE_LIB_FILE) ex-03-lib.c
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(HYPRE_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(HYPRE_LIB) $(LFLAGS)


# Rule for building ex-03-serial
ex-03-serial: ex-03-serial.c $(BRAID_LIB_FILE) $(HYPRE_LIB_FILE) ex-03-lib.c
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(HYPRE_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(HYPRE_LIB) $(LFLAGS)

# Rule for building ex-04
ex-04: ex-04.c $(BRAID_LIB_FILE) ex-04-lib.c
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for building ex-04-serial
ex-04-serial: ex-04-serial.c $(BRAID_LIB_FILE) ex-04-lib.c
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(@).c -o $@ $(BRAID_LIB_FILE) $(LFLAGS)

# Rule for compiling .c files
%: %.c $(BRAID_LIB_FILE)
    @echo "Building" $@ "..."
    $(MPICC) $(CFLAGS) $(BRAID_FLAGS) $(HYPRE_FLAGS) $(@).c -o $@\
 $(BRAID_LIB_FILE) $(HYPRE_LIB) $(LFLAGS)

# Rule for compiling .cpp files; links with mfem
%: %.cpp $(BRAID_LIB_FILE) $(MFEM_LIB_FILE) $(MFEM_CONFIG_MK)
    @echo "Building" $@ "..."
    $(MPICXX) $(CXXFLAGS) $(BRAID_FLAGS) $(MFEM_FLAGS) \
    $< -o $@ $(MFEM_LIBS) $(BRAID_LIB_FILE) $(LFLAGS)

# Generate an error message if the MFEM library is not built and exit
$(MFEM_LIB_FILE):
    $(error The MFEM library is not built)

# Generate an error message if the Hypre library is not built and exit
$(HYPRE_LIB_FILE):
    $(error The Hypre library is not built, unable to build ex-03)

clean: cleanout
    rm -f *.o $(C_NOHYPRE) $(CPP_NOHYPRE) $(F_NOHYPRE) $(C_EXAMPLES) $(CXX_EXAMPLES) $(F_EXAMPLES) *ror_norm* *_err_* *_mesh* *_sol_*
    rm -rf *.dSYM

cleanout:
    rm -f ex*.out.*

您似乎在尝试使用 C 编译器来编译 C++ 程序(或使用 C++ 库的程序)。如果不付出很多努力,这是行不通的,因为 C 编译器不知道在哪里可以找到 C++ 标准库和其他用于异常处理等内容的库。

您还没有发布您的 Makefile,但是如果您使用变量 CC 来编译并且 link 您的代码,请尝试切换到使用 CXX,这是C++ 编译器代替。