Search code examples
linuxcygwinlinker-errorsmpich

Link errơr using MPI compiler on Cygwin?


I tried to use Cygwin to build a MPI program. I have the error below. I am new user of Cygwin and I am struggling to learn it. Sorry if I don't understand something.

I am trying to use Xbraid package and to follow the instructions of user's manual but I got this error.

Can someone help?

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

The make file is :

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.*

Solution

  • It looks like you're trying to use a C compiler to compile a C++ program (or a program which uses a C++ library). That isn't going to work without a lot of effort, since the C compiler doesn't know where to find the C++ standard libraries and other libraries for things such as exception handling.

    You haven't posted your Makefile, but if you're using the variable CC to compile and link your code, try switching to using CXX, which is the C++ compiler instead.