1

I am trying to compile a code by Makefile. I received the code from github. I tried to implement the solution from links: [https://github.com/LLNL/scr/issues/130][1] [https://stackoverflow.com/questions/62461718/mpi-complile-error-undefined-reference-to-mpiwinfree][2], etc.

These solutions are not working for me or they are too technical. I am sorry to say as I am not from a programming background, it is difficult for me to understand.

The make file are as follows:

Makefile.include

.SUFFIXES: .cxx .cu .f90 .o
.PHONY: docs

CUDA_INSTALL_PATH = /usr/local/cuda

DEVICE  = cpu
#~ DEVICE  = gpu

CXX     = mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include
NVCC    = nvcc -Xcompiler "-fopenmp -O3" -std=c++11 -use_fast_math -I../include
FC      = mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
LFLAGS  = -D$(DEVICE) -lstdc++ -ldl -lm
#~ LFLAGS   += -lmpi_cxx
ifeq ($(DEVICE),gpu)
LFLAGS  += -lcudart
endif
OBJECT  = ../kernel/$(DEVICE)Laplace.o ../kernel/$(DEVICE)BiotSavart.o\
    ../kernel/$(DEVICE)Stretching.o ../kernel/$(DEVICE)Gaussian.o\
    ../kernel/$(DEVICE)CoulombVdW.o

.cxx.o:
    $(CXX) -c $? -o $@ $(LFLAGS)
.cu.o:
    $(NVCC) -c $? -o $@ $(LFLAGS)
.f90.o:
    $(FC) -c $? -o $@

and Makefile:

include ../Makefile.include
lib_parallel_ij: parallel_wrapper_ij.o $(OBJECT)
    ar -cr libfmm.a parallel_wrapper_ij.o $(OBJECT)
    ranlib libfmm.a

test_parallel_ij: test_parallel_ij.o
    make lib_parallel_ij
    $(FC) $? -L. -lfmm $(LFLAGS)
    mpirun -np 2 ./a.out

clean:
    make -C .. clean

When I am trying to compile it. It gives me the following errors:

mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include -c test_parallel_ij.f90 -o test_parallel_ij.o
make lib_parallel_ij
make[1]: Entering directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c parallel_wrapper_ij.cxx -o parallel_wrapper_ij.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuLaplace.cxx -o ../kernel/cpuLaplace.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuBiotSavart.cxx -o ../kernel/cpuBiotSavart.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuStretching.cxx -o ../kernel/cpuStretching.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuGaussian.cxx -o ../kernel/cpuGaussian.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuCoulombVdW.cxx -o ../kernel/cpuCoulombVdW.o -Dcpu -lstdc++ -ldl -lm
ar -cr libfmm.a parallel_wrapper_ij.o ../kernel/cpuLaplace.o ../kernel/cpuBiotSavart.o ../kernel/cpuStretching.o ../kernel/cpuGaussian.o ../kernel/cpuCoulombVdW.o
ranlib libfmm.a
make[1]: Leaving directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include test_parallel_ij.o -L. -lfmm -Dcpu -lstdc++ -ldl -lm
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool)':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/op_inln.h:121: undefined reference to `ompi_mpi_cxx_op_intercept'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Intracomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm_inln.h:23: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Graphcomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Cartcomm::Sub(bool const*) const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Intracomm::Create_graph(int, int const*, int const*, bool) const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Cartcomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o):/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: more undefined references to `MPI::Comm::Comm()' follow
./libfmm.a(parallel_wrapper_ij.o):(.data.rel.ro._ZTVN3MPI8DatatypeE[_ZTVN3MPI8DatatypeE]+0x78): undefined reference to `MPI::Datatype::Free()'
./libfmm.a(parallel_wrapper_ij.o):(.data.rel.ro._ZTVN3MPI3WinE[_ZTVN3MPI3WinE]+0x48): undefined reference to `MPI::Win::Free()'
collect2: error: ld returned 1 exit status
Makefile:48: recipe for target 'test_parallel_ij' failed
make: *** [test_parallel_ij] Error 1

I am unable to solve the error. I couldn't compile the code. I will be greatly helped if I can get some clue to compile it.

Thanks a lot. [1]: https://github.com/LLNL/scr/issues/130 [2]: MPI complile error, undefined reference to `MPI::Win::Free()

  • 2
    Looks like some definitions are missing from the build, and they look like they have something to do with MPI... `#~ LFLAGS += -lmpi_cxx` this line is commented out for some reason...maybe try uncommenting it and see what happens. – jackw11111 Nov 08 '21 at 02:11
  • @jackw11111 Thanks a lot for your reply. I did that but gives other errors. mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include test_parallel_ij.o -L. -lfmm -lmpi_cxx /usr/bin/ld: ./libfmm.a(parallel_wrapper_ij.o): undefined reference to symbol '_ZNSo9_M_insertIdEERSoT_@@GLIBCXX_3.4.9' //usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Makefile:48: recipe for target 'test_parallel_ij' failed – BideshSengupta Nov 08 '21 at 02:21
  • when I see `DSO missing from command line` I can usually add `-lpthread` to the libraries and it will solve it. Try adding it to the end of `LFLAGS` so: `LFLAGS += ... -lpthread`. – jackw11111 Nov 08 '21 at 02:23
  • @jackw11111. Thanks a lot for your suggestion. I did it, but still, the same error exists. – BideshSengupta Nov 08 '21 at 02:34
  • Could it be the same as [this?](https://stackoverflow.com/questions/33263288/libstdc-dso-missing-from-command-line) – jackw11111 Nov 08 '21 at 02:37
  • @jackw11111. Yeah I did that before. Instead of -std=c++11, tried with -lstdc++ as suggested in the link. But I couldn't solve the problem. I am very sorry to be so much illiterate in all these things. Kindly don't mind if I am being stupid. – BideshSengupta Nov 08 '21 at 02:46
  • The last thing I suggest is to check through the "issues" section on the github project page and search the error messages for others who have had the problem. Goodluck! – jackw11111 Nov 08 '21 at 02:49
  • @jackw11111. Thanks a lot for the suggestions. – BideshSengupta Nov 08 '21 at 03:06
  • You can use `objdump -t` on the libraries to see which library defines a symbol, and which ones access the symbols. Note that the library that defines the symbol must be _after_ the library (or object file) that accesses it on the linking command line. – HardcoreHenry Nov 08 '21 at 14:46
  • From: LFLAGS = -D$(DEVICE) -lstdc++ -ldl -lm To: LFLAGS = -D$(DEVICE) -lstdc++ -ldl -lm -lmpi_cxx.. solved the problem. – BideshSengupta Nov 09 '21 at 02:14

0 Answers0