undefined reference to `_gfortran_caf_*' errors

191 views
Skip to first unread message

Vishnu V. Krishnan

unread,
Jul 3, 2018, 1:28:47 PM7/3/18
to OpenCoarrays
I managed to compile version 2.1.0 with MPICH 3.2.1, and all the tests worked out fine.

But I'm unable to compile a simple program that utilises coarrays. It compiles fine with Intel's compiler. This is the output I get:

$ mpifort -fcoarray=lib coarray.f90
/tmp/cczhzK1I.o: In function `_caf_init.2.3819':
coarray.f90:(.text+0x6d): undefined reference to `_gfortran_caf_register'
coarray.f90:(.text+0xd2): undefined reference to `_gfortran_caf_register'
/tmp/cczhzK1I.o: In function `MAIN__':
coarray.f90:(.text+0x130): undefined reference to `_gfortran_caf_this_image'
coarray.f90:(.text+0x13c): undefined reference to `_gfortran_caf_this_image'
coarray.f90:(.text+0x163): undefined reference to `_gfortran_caf_sync_all'
coarray.f90:(.text+0x16d): undefined reference to `_gfortran_caf_this_image'
coarray.f90:(.text+0x185): undefined reference to `_gfortran_caf_num_images'
coarray.f90:(.text+0x199): undefined reference to `_gfortran_caf_num_images'
coarray.f90:(.text+0x20d): undefined reference to `_gfortran_caf_this_image'
coarray.f90:(.text+0x2e7): undefined reference to `_gfortran_caf_get'
coarray.f90:(.text+0x3cb): undefined reference to `_gfortran_caf_get'
/tmp/cczhzK1I.o: In function `main':
coarray.f90:(.text+0x458): undefined reference to `_gfortran_caf_init'
coarray.f90:(.text+0x484): undefined reference to `_gfortran_caf_finalize'
collect2: error: ld returned 1 exit status


Is it not detecting 'opecoarrays'?

Damian Rouson

unread,
Jul 3, 2018, 4:33:02 PM7/3/18
to Vishnu V. Krishnan, OpenCoarrays
Hi Vishu,

Thanks for your interest in OpenCoarrays.   After installing OpenCoarrays, you compile the "caf" compiler wrapper and run with the "cafrun" program launcher:

caf coarray.f90
$ cafrun -n 4 ./a.out

These wrappers provide several important services, including linking the libcaf_mpi library that contains the procedures that are shown as undefined in your attempt to compile.  In case it's of interest, you can also see how the "caf" wrapper will invoke gfortran, including any additional flags the wrapper passes, with the following command

$ caf --show

If you used the OpenCoarrays installer (install.sh), then your installation path will contain a setup.sh script that you can source to ensure that set up your environment, including insuring that the caf and cafrun scripts are in your PATH:

$ source /opt/opencoarrays/2.1.0/setup.sh

If you encounter further problems, please submit issues via https://github.com/sourceryinstitute/opencoarrays/issues

Damian

--
You received this message because you are subscribed to the Google Groups "OpenCoarrays" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencoarrays+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/opencoarrays.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencoarrays/d3ff0dbe-e93d-43ce-ba0e-18c652a048d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zaak Beekman

unread,
Jul 3, 2018, 5:59:58 PM7/3/18
to OpenCoarrays
Hi Vishnu,

To me this looks like you're not linking in libcaf_mpi.a (or libcaf_mpi.so). You will need a `-lcaf_mpi` in your link line, but there may be further issues: For static libs the link order matters. If you are linking a shared libcaf_mpi the the dynamic linker needs to find libcaf_mpi.so at runtime so you may need to modify LD_LIBRARY_PATH or put it somewhere "normal" etc.

To elaborate a little bit further on what Damian said, there are a few possible pitfalls that the wrapper scripts help you avoid:

1. You must take care with MPI wrappers which compiler is being wrapped. The version of OpenCoarrays you build is, in general, only compatible with the version of GFortran used as the compiler during installation and the version of MPI linked against
2. MPI might require you to use extra MPI flags
3. Link order
etc.

Best,
Zaak

Vishnu V. Krishnan

unread,
Jul 4, 2018, 1:45:23 AM7/4/18
to openco...@googlegroups.com
@Damian,

I installed it through the AUR (Arch User Repository), which uses the 'cmake' way of installing it.

When I try it with 'caf', I get another error:

    gfortran: error: /usr/lib/libcaf_mpi.a: No such file or directory
   
Error: comand:
       
`/usr/bin/gfortran -I/usr/include/OpenCoarrays-2.1.0_GNU-8.1.1 -fcoarray=lib -Wl,-rpath -Wl,/opt/mpich/lib -Wl,--enable-new-dtags coarray.f90 /usr/lib/libcaf_mpi.a /opt/mpich/lib/libmpifort.so /opt/mpich/lib/libmpi.so`
    failed to compile
.

There is no 'setup.sh' script amongst the files installed.

It is possible that this error is due to the MPICH executables in Arch, existing in /opt, which has a lower priority, which is probably why it works when I specifically use it, as below:

@Zaak

Thanks for that! It works now! The installation via 'cmake' puts the library files in /usr/lib, so it is able to find it. It compiles and runs fine without error, when I do:

    /opt/mpich/bin/mpifort -fcoarray=lib coarray.f90 -lcaf_mpi

Zaak Beekman

unread,
Jul 5, 2018, 12:03:43 PM7/5/18
to OpenCoarrays
I installed it through the AUR (Arch User Repository), which uses the 'cmake' way of installing it.

When I try it with 'caf', I get another error:

    gfortran: error: /usr/lib/libcaf_mpi.a: No such file or directory
   
Error: comand:
       
`/usr/bin/gfortran -I/usr/include/OpenCoarrays-2.1.0_GNU-8.1.1 -fcoarray=lib -Wl,-rpath -Wl,/opt/mpich/lib -Wl,--enable-new-dtags coarray.f90 /usr/lib/libcaf_mpi.a /opt/mpich/lib/libmpifort.so /opt/mpich/lib/libmpi.so`
    failed to compile
.

 Do you have a `/usr/lib/libcaf_mpi.a`? Is there a way to see what and where files are installed via aur?

Vishnu V. Krishnan

unread,
Jul 5, 2018, 12:46:49 PM7/5/18
to openco...@googlegroups.com

On Thursday, 5 July 2018 16:03:43 UTC, Zaak Beekman wrote:

 Do you have a `/usr/lib/libcaf_mpi.a`? Is there a way to see what and where files are installed via aur?

Yes, these are the files made by the AUR  install script, using cmake. Below is also a link to the script:


/usr/bin/caf
/usr/bin/cafrun

/usr/include/ISO_Fortran_binding.h
/
usr/include/OpenCoarrays-2.1.0_GNU-8.1.1/opencoarrays.mod
/usr/include/libcaf-gfortran-descriptor.h
/usr/include/libcaf.h
/usr/include/opencoarrays.mod

/usr/lib/cmake/opencoarrays/OpenCoarraysConfig.cmake
/usr/lib/cmake/opencoarrays/OpenCoarraysConfigVersion.cmake
/usr/lib/cmake/opencoarrays/OpenCoarraysTargets-release.cmake
/usr/lib/cmake/opencoarrays/OpenCoarraysTargets.cmake
/usr/lib/libISO_Fortran_binding.so
/usr/lib/libISO_Fortran_binding.so.1
/usr/lib/libISO_Fortran_binding.so.2.1.0
/usr/lib/libcaf_mpi.so
/usr/lib/libcaf_mpi.so.3

/
usr/share/licenses/opencoarrays/LICENSE

/usr/share/man/man1/caf.1.gz
/usr/share/man/man1/cafrun.1.gz


Zaak Beekman

unread,
Jul 5, 2018, 1:07:54 PM7/5/18
to Vishnu V. Krishnan, OpenCoarrays
Ah, it looks like the package is installing only the .so. Maybe I should add some logic to the caf script to look for the .so if the static archive is missing.
/
/
usr/share/licenses/opencoarrays/LICENSE

/usr/share/man/man1/caf.1.gz
/usr/share/man/man1/cafrun.1.gz


--
You received this message because you are subscribed to a topic in the Google Groups "OpenCoarrays" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/opencoarrays/uRlWSby8dY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to opencoarrays...@googlegroups.com.

ga...@yellowstone.energy

unread,
Sep 4, 2018, 10:32:46 PM9/4/18
to OpenCoarrays
Hi,

As an update, I also tried to install this thruogh the AUR but encounter the same issue. Seems only .so files get installed but no .a that caf looks for.

Zaak Beekman

unread,
Sep 5, 2018, 9:27:28 AM9/5/18
to ga...@yellowstone.energy, OpenCoarrays
Hi Gavin,

I will work up a fix for this in the next release. Is there any chance the AUR package maintainer would be amenable to installing the static kind too? Or would this suggestion be a non-starter?

Thanks,
Zaak

ga...@yellowstone.energy

unread,
Sep 5, 2018, 10:55:32 AM9/5/18
to OpenCoarrays
Well that would be a question for this individual:

# Contributor: James Clark <s112...@sms.ed.ac.uk>

I can send an email if you like but you could probably describe the problem much better.

Vishnu V. Krishnan

unread,
Sep 6, 2018, 12:00:39 AM9/6/18
to OpenCoarrays
I think it would be a waste to compile statically when the point of the AUR is to have locally built installations. Of course users are free to add flags to the build-script to make it so.

@Gavin  The AUR page currently has instructions for how to compile/run using the shared libraries, and it works. Did you try that? If you want to use 'caf', you can just change the `/usr/bin/caf` script. There is one instance of `libcaf_mpi.a`. Change it to `libcaf_mpi.so`.

On Wednesday, 5 September 2018 13:27:28 UTC, Zaak Beekman wrote:
Hi Gavin,

I will work up a fix for this in the next release. Is there any chance the AUR package maintainer would be amenable to installing the static kind too? Or would this suggestion be a non-starter?

Thanks,
Zaak
Reply all
Reply to author
Forward
0 new messages