Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Discussion about building and installing Elmer
Post Reply
andythe_great
Posts: 10
Joined: 01 Oct 2021, 01:02
Antispam: Yes

Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by andythe_great »

Hello,
I want to package Elmer as Flatpak for Linux distros.
https://www.flatpak.org/
I came across this error.

Code: Select all

[ 67%] Linking CXX executable ElmerGUI
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/BackwardError.F90.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/11.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lMPI::MPI_C
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/Interpolation.F90.o
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/BandwidthOptimize.F90.o
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/Maxwell.F90.o
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/MaxwellGeneral.F90.o
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/MaxwellAxiS.F90.o
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/Differentials.F90.o
[ 67%] Building Fortran object fem/src/CMakeFiles/elmersolver.dir/StressGeneral.F90.o
collect2: error: ld returned 1 exit status
make[2]: *** [ElmerGUI/Application/CMakeFiles/ElmerGUI.dir/build.make:1366: ElmerGUI/Application/ElmerGUI] Error 1
make[1]: *** [CMakeFiles/Makefile2:25231: ElmerGUI/Application/CMakeFiles/ElmerGUI.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
I am wondering what is -lMPI::MPI_C ? I kind of understand the -lMPI part, but the ::MPI_C is confusing to me.
I'm not sure which MPI Elmer need, so I install both openmpi 4.1.1 and mpich 4.0.1.

I tried running

Code: Select all

ld -lMPI::MPI_C --verbose
Just before building Elmer and got this.

Code: Select all

ld: mode elf_x86_64
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libMPI::MPI_C.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libMPI::MPI_C.a failed
attempt to open /usr/lib/x86_64-linux-gnu/libMPI::MPI_C.so failed
attempt to open /usr/lib/x86_64-linux-gnu/libMPI::MPI_C.a failed
attempt to open /usr/lib/libMPI::MPI_C.so failed
attempt to open /usr/lib/libMPI::MPI_C.a failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib/libMPI::MPI_C.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib/libMPI::MPI_C.a failed
ld: cannot find -lMPI::MPI_C
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libMPI::MPI_C.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/MPI::MPI_C.a failed
attempt to open /usr/lib/x86_64-linux-gnu/libMPI::MPI_C.so failed
attempt to open /usr/lib/x86_64-linux-gnu/MPI::MPI_C.a failed
attempt to open /usr/lib/libMPI::MPI_C.so failed
attempt to open /usr/lib/MPI::MPI_C.a failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib/libMPI::MPI_C.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib/MPI::MPI_C.a failed
Error: module test: Child process exited with code 1
So it is looking for libMPI::MPI_C library. But there are no such thing.
Only this exist.

Code: Select all

andy@localhost:~/Desktop/Flatpak/fi.csc.Elmer/build/files/lib> ls -l | grep -i mpi
lrwxrwxrwx 1 andy users        13 Mar 23 09:17 libfmpich.so -> libmpifort.so
-rwxr-xr-x 2 andy users      1019 Jan  1  1970 libmca_common_ompio.la
lrwxrwxrwx 1 andy users        30 Mar 23 09:17 libmca_common_ompio.so -> libmca_common_ompio.so.41.29.1
lrwxrwxrwx 1 andy users        30 Mar 23 09:17 libmca_common_ompio.so.41 -> libmca_common_ompio.so.41.29.1
-rwxr-xr-x 2 andy users     63632 Jan  1  1970 libmca_common_ompio.so.41.29.1
-rw-r--r-- 2 andy users 205818154 Jan  1  1970 libmpi.a
lrwxrwxrwx 1 andy users        12 Mar 23 09:17 libmpichcxx.so -> libmpicxx.so
lrwxrwxrwx 1 andy users        13 Mar 23 09:17 libmpichf90.so -> libmpifort.so
lrwxrwxrwx 1 andy users         9 Mar 23 09:17 libmpich.so -> libmpi.so
-rw-r--r-- 2 andy users    606860 Jan  1  1970 libmpicxx.a
-rwxr-xr-x 2 andy users      1006 Jan  1  1970 libmpicxx.la
-rwxr-xr-x 2 andy users      1083 Jan  1  1970 libMPI_cxx.la
lrwxrwxrwx 1 andy users        19 Mar 23 09:17 libmpicxx.so -> libmpicxx.so.12.2.1
lrwxrwxrwx 1 andy users        21 Mar 23 09:17 libMPI_cxx.so -> libMPI_cxx.so.40.30.0
lrwxrwxrwx 1 andy users        19 Mar 23 09:17 libmpicxx.so.12 -> libmpicxx.so.12.2.1
-rwxr-xr-x 2 andy users    157816 Jan  1  1970 libmpicxx.so.12.2.1
lrwxrwxrwx 1 andy users        21 Mar 23 09:17 libMPI_cxx.so.40 -> libMPI_cxx.so.40.30.0
-rwxr-xr-x 2 andy users    121120 Jan  1  1970 libMPI_cxx.so.40.30.0
-rw-r--r-- 2 andy users   1851830 Jan  1  1970 libmpifort.a
-rwxr-xr-x 2 andy users      1013 Jan  1  1970 libmpifort.la
lrwxrwxrwx 1 andy users        20 Mar 23 09:17 libmpifort.so -> libmpifort.so.12.2.1
lrwxrwxrwx 1 andy users        20 Mar 23 09:17 libmpifort.so.12 -> libmpifort.so.12.2.1
-rwxr-xr-x 2 andy users    826792 Jan  1  1970 libmpifort.so.12.2.1
-rwxr-xr-x 2 andy users       970 Jan  1  1970 libmpi.la
-rwxr-xr-x 2 andy users      1044 Jan  1  1970 libMPI.la
-rwxr-xr-x 2 andy users      1099 Jan  1  1970 libMPI_mpifh.la
lrwxrwxrwx 1 andy users        23 Mar 23 09:17 libMPI_mpifh.so -> libMPI_mpifh.so.40.30.0
lrwxrwxrwx 1 andy users        23 Mar 23 09:17 libMPI_mpifh.so.40 -> libMPI_mpifh.so.40.30.0
-rwxr-xr-x 2 andy users    456736 Jan  1  1970 libMPI_mpifh.so.40.30.0
lrwxrwxrwx 1 andy users        16 Mar 23 09:17 libmpi.so -> libmpi.so.12.2.1
lrwxrwxrwx 1 andy users        17 Mar 23 09:17 libMPI.so -> libMPI.so.40.30.1
lrwxrwxrwx 1 andy users        16 Mar 23 09:17 libmpi.so.12 -> libmpi.so.12.2.1
-rwxr-xr-x 2 andy users  40517904 Jan  1  1970 libmpi.so.12.2.1
lrwxrwxrwx 1 andy users        17 Mar 23 09:17 libMPI.so.40 -> libMPI.so.40.30.1
-rwxr-xr-x 2 andy users   1097592 Jan  1  1970 libMPI.so.40.30.1
-rwxr-xr-x 2 andy users      1144 Jan  1  1970 libMPI_usempif08.la
lrwxrwxrwx 1 andy users        27 Mar 23 09:17 libMPI_usempif08.so -> libMPI_usempif08.so.40.30.0
lrwxrwxrwx 1 andy users        27 Mar 23 09:17 libMPI_usempif08.so.40 -> libMPI_usempif08.so.40.30.0
-rwxr-xr-x 2 andy users    297952 Jan  1  1970 libMPI_usempif08.so.40.30.0
-rwxr-xr-x 2 andy users      1093 Jan  1  1970 libMPI_usempi_ignore_tkr.la
lrwxrwxrwx 1 andy users        35 Mar 23 09:17 libMPI_usempi_ignore_tkr.so -> libMPI_usempi_ignore_tkr.so.40.30.0
lrwxrwxrwx 1 andy users        35 Mar 23 09:17 libMPI_usempi_ignore_tkr.so.40 -> libMPI_usempi_ignore_tkr.so.40.30.0
-rwxr-xr-x 2 andy users     59152 Jan  1  1970 libMPI_usempi_ignore_tkr.so.40.30.0
lrwxrwxrwx 1 andy users         9 Mar 23 09:17 libmpl.so -> libmpi.so
-rwxr-xr-x 2 andy users       977 Jan  1  1970 libompitrace.la
lrwxrwxrwx 1 andy users        23 Mar 23 09:17 libompitrace.so -> libompitrace.so.40.30.0
lrwxrwxrwx 1 andy users        23 Mar 23 09:17 libompitrace.so.40 -> libompitrace.so.40.30.0
-rwxr-xr-x 2 andy users     22568 Jan  1  1970 libompitrace.so.40.30.0
lrwxrwxrwx 1 andy users         9 Mar 23 09:17 libopa.so -> libmpi.so
-rwxr-xr-x 2 andy users       997 Jan  1  1970 libopen-orted-mpir.la
-rwxr-xr-x 2 andy users     14008 Jan  1  1970 libopen-orted-mpir.so
lrwxrwxrwx 1 andy users        33 Mar 23 09:17 libvtkFiltersParallelMPI-9.1.so -> libvtkFiltersParallelMPI-9.1.so.1
lrwxrwxrwx 1 andy users        37 Mar 23 09:17 libvtkFiltersParallelMPI-9.1.so.1 -> libvtkFiltersParallelMPI-9.1.so.9.1.0
-rwxr-xr-x 2 andy users    129248 Jan  1  1970 libvtkFiltersParallelMPI-9.1.so.9.1.0
lrwxrwxrwx 1 andy users        25 Mar 23 09:17 libvtkIOMPIImage-9.1.so -> libvtkIOMPIImage-9.1.so.1
lrwxrwxrwx 1 andy users        29 Mar 23 09:17 libvtkIOMPIImage-9.1.so.1 -> libvtkIOMPIImage-9.1.so.9.1.0
-rwxr-xr-x 2 andy users     88280 Jan  1  1970 libvtkIOMPIImage-9.1.so.9.1.0
lrwxrwxrwx 1 andy users        28 Mar 23 09:17 libvtkIOMPIParallel-9.1.so -> libvtkIOMPIParallel-9.1.so.1
lrwxrwxrwx 1 andy users        32 Mar 23 09:17 libvtkIOMPIParallel-9.1.so.1 -> libvtkIOMPIParallel-9.1.so.9.1.0
-rwxr-xr-x 2 andy users    125152 Jan  1  1970 libvtkIOMPIParallel-9.1.so.9.1.0
lrwxrwxrwx 1 andy users        26 Mar 23 09:17 libvtkParallelMPI-9.1.so -> libvtkParallelMPI-9.1.so.1
lrwxrwxrwx 1 andy users        30 Mar 23 09:17 libvtkParallelMPI-9.1.so.1 -> libvtkParallelMPI-9.1.so.9.1.0
-rwxr-xr-x 2 andy users     96472 Jan  1  1970 libvtkParallelMPI-9.1.so.9.1.0
-rwxr-xr-x 2 andy users      5922 Jan  1  1970 mpi_ext.mod
-rwxr-xr-x 2 andy users      1623 Jan  1  1970 mpi_f08_callbacks.mod
-rwxr-xr-x 2 andy users      9933 Jan  1  1970 mpi_f08_ext.mod
-rwxr-xr-x 2 andy users      1995 Jan  1  1970 mpi_f08_interfaces_callbacks.mod
-rwxr-xr-x 2 andy users     50479 Jan  1  1970 mpi_f08_interfaces.mod
-rwxr-xr-x 2 andy users    119353 Jan  1  1970 mpi_f08.mod
-rwxr-xr-x 2 andy users     13842 Jan  1  1970 mpi_f08_types.mod
-rwxr-xr-x 2 andy users     95306 Jan  1  1970 mpi.mod
-rwxr-xr-x 2 andy users      1132 Jan  1  1970 ompi_monitoring_prof.la
-rwxr-xr-x 2 andy users     22568 Jan  1  1970 ompi_monitoring_prof.so
drwxr-xr-x 1 andy users      7416 Jan  1  1970 openmpi
-rwxr-xr-x 2 andy users     50550 Jan  1  1970 pmpi_f08_interfaces.mod
My Flatpak build manifest.
https://github.com/kevinsmia1939/flathu ... .csc.Elmer

Thanks
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by kevinarden »

I think the error is just gcc's way of say it can not find the mpi library.
with the verbose on it lists all of the places it looked by default
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libMPI::MPI_C.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib64/libMPI::MPI_C.a failed
attempt to open /usr/lib/x86_64-linux-gnu/libMPI::MPI_C.so failed
attempt to open /usr/lib/x86_64-linux-gnu/libMPI::MPI_C.a failed
attempt to open /usr/lib/libMPI::MPI_C.so failed
attempt to open /usr/lib/libMPI::MPI_C.a failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib/libMPI::MPI_C.so failed
attempt to open /usr/x86_64-unknown-linux-gnu/lib/libMPI::MPI_C.a failed

but it never looked in /app/lib

https://askubuntu.com/questions/540047/ ... enmpi-code
andythe_great
Posts: 10
Joined: 01 Oct 2021, 01:02
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by andythe_great »

Thanks for reply.

I try adding this cflag

Code: Select all

-L /app/lib -lMPI::MPI_C
Which result in error.

Code: Select all

    Run Build Command(s):/usr/bin/make -f Makefile cmTC_aefc3/fast && /usr/bin/make  -f CMakeFiles/cmTC_aefc3.dir/build.make CMakeFiles/cmTC_aefc3.dir/build
    make[1]: Entering directory '/run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_aefc3.dir/testCCompiler.c.o
    /usr/bin/cc   -L /app/lib -lMPI::MPI_C  -o CMakeFiles/cmTC_aefc3.dir/testCCompiler.c.o -c /run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_aefc3
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_aefc3.dir/link.txt --verbose=1
    /usr/bin/cc -L /app/lib -lMPI::MPI_C  -L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed  -rdynamic CMakeFiles/cmTC_aefc3.dir/testCCompiler.c.o -o cmTC_aefc3 
    /usr/lib/gcc/x86_64-unknown-linux-gnu/11.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lMPI::MPI_C
    collect2: error: ld returned 1 exit status
    make[1]: *** [CMakeFiles/cmTC_aefc3.dir/build.make:99: cmTC_aefc3] Error 1
    make[1]: Leaving directory '/run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:127: cmTC_aefc3/fast] Error 2
However, when just using this.

Code: Select all

-L /app/lib -lmpi -lMPI
It does no result in above error, but original error of this question remain.
I conclude that MPI does exist and it was found, but MPI::MPI_C is not. Which I don't lnow if it is different.
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by kevinarden »

I think the ::MPI_C is just part of the error message that that it can not find the MPI library. I believe the library is -lMPI
andythe_great
Posts: 10
Joined: 01 Oct 2021, 01:02
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by andythe_great »

I tried making link.

Code: Select all

ln -s /app/lib/libMPI.so /app/lib/libMPI::MPI_C.so
and it worked, seems like ::MPI_C is actually part of the name.
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by kevinarden »

Do you know if just
ln -s /app/lib/libMPI.so

would have worked?
andythe_great
Posts: 10
Joined: 01 Oct 2021, 01:02
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by andythe_great »

It does not work.

Code: Select all

CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make -f Makefile cmTC_e7dd3/fast && /usr/bin/make  -f CMakeFiles/cmTC_e7dd3.dir/build.make CMakeFiles/cmTC_e7dd3.dir/build
    make[1]: Entering directory '/run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_e7dd3.dir/testCCompiler.c.o
    /usr/bin/cc   -L /app/lib -lmpi -lMPI -lMPI::MPI_C  -o CMakeFiles/cmTC_e7dd3.dir/testCCompiler.c.o -c /run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_e7dd3
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e7dd3.dir/link.txt --verbose=1
    /usr/bin/cc -L /app/lib -lmpi -lMPI -lMPI::MPI_C  -L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed  -rdynamic CMakeFiles/cmTC_e7dd3.dir/testCCompiler.c.o -o cmTC_e7dd3 
    /usr/lib/gcc/x86_64-unknown-linux-gnu/11.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lMPI::MPI_C
    collect2: error: ld returned 1 exit status
    make[1]: *** [CMakeFiles/cmTC_e7dd3.dir/build.make:99: cmTC_e7dd3] Error 1
    make[1]: Leaving directory '/run/build/Elmer/_flatpak_build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:127: cmTC_e7dd3/fast] Error 2
SwizzlaKalongie
Posts: 4
Joined: 07 Sep 2022, 04:17
Antispam: Yes

Re: Need help building Elmer as Flatpak Linux. ld: cannot find -lMPI::MPI_C

Post by SwizzlaKalongie »

Hi,
Has there been any progress on this? So far I've been trying and failing to get Elmer built on anything other than Ubuntu so I'm really hoping for a flatpak.
Post Reply