0

I inherited a rather large project that I am trying to get to compile (it's a bit old, maybe 10 years). I am trying to use new intel compilers with intel mpi on Ubuntu WSL.

There are some C modules and some fortran modules that I compile like so:

C Module:

mpiicc -g -DUSE_MPI_IO -Dlinux -DUse_Intel_Fortran -MP -D_FILE_OFFSET_BITS=64 -w -DLONG64 -O -L/home/xxx/intel/2024.2.1/oneapi/mpi/latest/lib -D__MPI__ -I/home/xxx/intel/2024.2.1/oneapi/mpi/latest/include -I. -c -o module_a.o module_a.c

Fortran Module:

mpiifort -g -c -I. -DUse_Intel_Fortran -MP -w -O -D__MPI__ -I/home/xxxx/intel/2024.2.1/oneapi/mpi/latest/include -L/home/xxx/intel/2024.2.1/oneapi/mpi/latest/lib module_b.f90

These compile just fine, but then I try to link these objects to the c compiler:

mpiicc -g -v -O -o final.x module_a.o module_b.o -lm -lmpi -L/home/xxx/intel/2024.2.1/oneapi/mpi/latest/lib

And I get a bunch of undefined reference MPI errors only for the fortran modules:

module_b.o:(.text+0x1838c): undefined reference to "mpi_send_"

module_b.o:(.text+0x1838c): undefined reference to "mpi_abort_"

Seems like I'm doing something stupid, but I can't find many other cases of people doing this for reference.

Any help is appreciated!

edit to correct a mistake, the errors are only for the fortran modules, not the C modules

4
  • -o -I doesn't look right. Your binary will be named -I. You don't need -I for linking. Two possible approaches to solve your missing symbols: use the Fortran compiler for linking. It might require an extra flag to tell the Fortran compiler to do not generate a main function if that comes from C. Alternatively, you will need to explicitly link the MPI Fortran library. Find out, what mpiifort links additionally by checking ifort -show Commented Oct 24, 2024 at 23:31
  • 1
    you might simply want to link with the Fortran wrapper (e.g. mpiifort). If not, you need to manually link with the Fortran MPI library (e.g. -lmpifort) Commented Oct 25, 2024 at 0:14
  • 1
    @GillesGouaillardet Ah, -lmpifort was what I was missing, thanks so much. Commented Oct 25, 2024 at 17:11
  • @Joachim You are correct, but that was actually at typo I introduced into the post, thank you! Commented Oct 25, 2024 at 17:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.