scivision / mumps

MUMPS via CMake
http://mumps-solver.org
MIT License
115 stars 46 forks source link

Linking error with FetchContent #8

Closed puneetmatharu closed 3 years ago

puneetmatharu commented 3 years ago

I was previously working with an older version of your library that I forked and patched (for my own usage), but I thought I'd give your latest version a shot. My old version still works but the latest version doesn't. When I try to integrate the MUMPS project into my own using FetchContent, I encounter what appears to be a linking error (output provided below) at build time. Have you encountered this issue yourself at all, or know how to fix it?

For reference, I'm working on macOS and using a Clang compiler.

Thanks!

FAILED: _deps/mumps_project-build/tests/d_simple 
: && /usr/local/bin/gfortran -Wl,-flat_namespace -Wl,-commons,use_dylibs -L/usr/local/Cellar/libevent/2.1.12/lib -L/usr/local/Cellar/libevent/2.1.12/lib -fimplicit-none -fallow-argument-mismatch -fallow-invalid-boz -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk _deps/mumps_project-build/tests/CMakeFiles/d_simple.dir/d_simple.f90.o -o _deps/mumps_project-build/tests/d_simple  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib  _deps/mumps_project-build/libsmumpsd.a  _deps/mumps_project-build/libdmumpsd.a  _deps/mumps_project-build/libmumps_commond.a  /usr/local/lib/libscalapack.a  -lm  -ldl  -framework  Accelerate  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempif08.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempi_ignore_tkr.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_mpifh.dylib  _deps/mumps_project-build/libpordd.a  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib && :
Undefined symbols for architecture x86_64:
  "_Cblacs_abort", referenced from:
      _PB_Cabort in libscalapack.a(PB_Cabort.c.o)
      _PB_Cmalloc in libscalapack.a(PB_Cmalloc.c.o)
  "_Cblacs_gridinfo", referenced from:
      _pdtrsm_ in libscalapack.a(pdtrsm_.c.o)
      _PB_Cabort in libscalapack.a(PB_Cabort.c.o)
      _PB_Cchkmat in libscalapack.a(PB_Cchkmat.c.o)
      _PB_Cplapad in libscalapack.a(PB_Cplapad.c.o)
      _PB_CptrsmAB in libscalapack.a(PB_CptrsmAB.c.o)
      _PB_CptrsmB in libscalapack.a(PB_CptrsmB.c.o)
      _PB_Cwarn in libscalapack.a(PB_Cwarn.c.o)
      ...
  "_Cblacs_pnum", referenced from:
      _PB_Cwarn in libscalapack.a(PB_Cwarn.c.o)
  "_Cdgamx2d", referenced from:
      _pdamax_ in libscalapack.a(pdamax_.c.o)
  "_Cdgebr2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgebs2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgerv2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgesd2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgsum2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
  "_Cigebr2d", referenced from:
      _pdamax_ in libscalapack.a(pdamax_.c.o)
  "_Cigebs2d", referenced from:
      _pdamax_ in libscalapack.a(pdamax_.c.o)
  "_blacs_abort_", referenced from:
      _pdgetf2_ in libscalapack.a(pdgetf2.f.o)
      _pdpotf2_ in libscalapack.a(pdpotf2.f.o)
  "_blacs_gridexit_", referenced from:
      _dmumps_end_driver_ in libdmumpsd.a(dend_driver.F.o)
      _dmumps_init_root_ana_ in libdmumpsd.a(dtype3_root.F.o)
  "_blacs_gridinfo_", referenced from:
      _dmumps_init_root_ana_ in libdmumpsd.a(dtype3_root.F.o)
      _dmumps_root_solve_ in libdmumpsd.a(dsol_root_parallel.F.o)
      _descinit_ in libscalapack.a(descinit.f.o)
      _pdgetrs_ in libscalapack.a(pdgetrs.f.o)
      _pdpotrs_ in libscalapack.a(pdpotrs.f.o)
      _chk1mat_ in libscalapack.a(chk1mat.f.o)
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      ...
  "_blacs_gridinit_", referenced from:
      ___dmumps_save_restore_MOD_dmumps_save_restore_structure in libdmumpsd.a(dmumps_save_restore.F.o)
      _dmumps_init_root_ana_ in libdmumpsd.a(dtype3_root.F.o)
  "_igamn2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pdgetrf_ in libscalapack.a(pdgetrf.f.o)
  "_igebr2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pdlapiv_ in libscalapack.a(pdlapiv.f.o)
      _pdgetf2_ in libscalapack.a(pdgetf2.f.o)
      _pdlapv2_ in libscalapack.a(pdlapv2.f.o)
      _pdpotf2_ in libscalapack.a(pdpotf2.f.o)
  "_igebs2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pdlapiv_ in libscalapack.a(pdlapiv.f.o)
      _pdgetf2_ in libscalapack.a(pdgetf2.f.o)
      _pdlapv2_ in libscalapack.a(pdlapv2.f.o)
      _pdpotf2_ in libscalapack.a(pdpotf2.f.o)
  "_igerv2d_", referenced from:
      _picol2row_ in libscalapack.a(picol2row.f.o)
      _pirow2col_ in libscalapack.a(pirow2col.f.o)
  "_igesd2d_", referenced from:
      _picol2row_ in libscalapack.a(picol2row.f.o)
      _pirow2col_ in libscalapack.a(pirow2col.f.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
[3116/4063] Linking Fortran executable _deps/mumps_project-build/tests/mumpscfg
FAILED: _deps/mumps_project-build/tests/mumpscfg 
: && /usr/local/bin/gfortran -Wl,-flat_namespace -Wl,-commons,use_dylibs -L/usr/local/Cellar/libevent/2.1.12/lib -L/usr/local/Cellar/libevent/2.1.12/lib -fimplicit-none -fallow-argument-mismatch -fallow-invalid-boz -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk _deps/mumps_project-build/tests/CMakeFiles/mumpscfg.dir/test_mumps.f90.o -o _deps/mumps_project-build/tests/mumpscfg  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib  _deps/mumps_project-build/libsmumpsd.a  _deps/mumps_project-build/libdmumpsd.a  _deps/mumps_project-build/libmumps_commond.a  /usr/local/lib/libscalapack.a  -lm  -ldl  -framework  Accelerate  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempif08.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempi_ignore_tkr.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_mpifh.dylib  _deps/mumps_project-build/libpordd.a  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib && :
Undefined symbols for architecture x86_64:
  "_Cblacs_abort", referenced from:
      _PB_Cabort in libscalapack.a(PB_Cabort.c.o)
      _PB_Cmalloc in libscalapack.a(PB_Cmalloc.c.o)
  "_Cblacs_gridinfo", referenced from:
      _pdtrsm_ in libscalapack.a(pdtrsm_.c.o)
      _PB_Cabort in libscalapack.a(PB_Cabort.c.o)
      _PB_Cchkmat in libscalapack.a(PB_Cchkmat.c.o)
      _PB_Cplapad in libscalapack.a(PB_Cplapad.c.o)
      _PB_CptrsmAB in libscalapack.a(PB_CptrsmAB.c.o)
      _PB_CptrsmB in libscalapack.a(PB_CptrsmB.c.o)
      _PB_Cwarn in libscalapack.a(PB_Cwarn.c.o)
      ...
  "_Cblacs_pnum", referenced from:
      _PB_Cwarn in libscalapack.a(PB_Cwarn.c.o)
  "_Cdgamx2d", referenced from:
      _pdamax_ in libscalapack.a(pdamax_.c.o)
  "_Cdgebr2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgebs2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgerv2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgesd2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
      _pdamax_ in libscalapack.a(pdamax_.c.o)
      _pdswap_ in libscalapack.a(pdswap_.c.o)
  "_Cdgsum2d", referenced from:
      _PB_Cdtypeset in libscalapack.a(PB_Cdtypeset.c.o)
  "_Cigebr2d", referenced from:
      _pdamax_ in libscalapack.a(pdamax_.c.o)
  "_Cigebs2d", referenced from:
      _pdamax_ in libscalapack.a(pdamax_.c.o)
  "_blacs_abort_", referenced from:
      _pdgetf2_ in libscalapack.a(pdgetf2.f.o)
      _pdpotf2_ in libscalapack.a(pdpotf2.f.o)
  "_blacs_gridexit_", referenced from:
      _dmumps_end_driver_ in libdmumpsd.a(dend_driver.F.o)
      _dmumps_init_root_ana_ in libdmumpsd.a(dtype3_root.F.o)
  "_blacs_gridinfo_", referenced from:
      _dmumps_init_root_ana_ in libdmumpsd.a(dtype3_root.F.o)
      _dmumps_root_solve_ in libdmumpsd.a(dsol_root_parallel.F.o)
      _descinit_ in libscalapack.a(descinit.f.o)
      _pdgetrs_ in libscalapack.a(pdgetrs.f.o)
      _pdpotrs_ in libscalapack.a(pdpotrs.f.o)
      _chk1mat_ in libscalapack.a(chk1mat.f.o)
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      ...
  "_blacs_gridinit_", referenced from:
      ___dmumps_save_restore_MOD_dmumps_save_restore_structure in libdmumpsd.a(dmumps_save_restore.F.o)
      _dmumps_init_root_ana_ in libdmumpsd.a(dtype3_root.F.o)
  "_igamn2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pdgetrf_ in libscalapack.a(pdgetrf.f.o)
  "_igebr2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pdlapiv_ in libscalapack.a(pdlapiv.f.o)
      _pdgetf2_ in libscalapack.a(pdgetf2.f.o)
      _pdlapv2_ in libscalapack.a(pdlapv2.f.o)
      _pdpotf2_ in libscalapack.a(pdpotf2.f.o)
  "_igebs2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pdlapiv_ in libscalapack.a(pdlapiv.f.o)
      _pdgetf2_ in libscalapack.a(pdgetf2.f.o)
      _pdlapv2_ in libscalapack.a(pdlapv2.f.o)
      _pdpotf2_ in libscalapack.a(pdpotf2.f.o)
  "_igerv2d_", referenced from:
      _picol2row_ in libscalapack.a(picol2row.f.o)
      _pirow2col_ in libscalapack.a(pirow2col.f.o)
  "_igesd2d_", referenced from:
      _picol2row_ in libscalapack.a(picol2row.f.o)
      _pirow2col_ in libscalapack.a(pirow2col.f.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
[3117/4063] Linking Fortran executable _deps/mumps_project-build/tests/s_simple
FAILED: _deps/mumps_project-build/tests/s_simple 
: && /usr/local/bin/gfortran -Wl,-flat_namespace -Wl,-commons,use_dylibs -L/usr/local/Cellar/libevent/2.1.12/lib -L/usr/local/Cellar/libevent/2.1.12/lib -fimplicit-none -fallow-argument-mismatch -fallow-invalid-boz -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk _deps/mumps_project-build/tests/CMakeFiles/s_simple.dir/s_simple.f90.o -o _deps/mumps_project-build/tests/s_simple  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib  _deps/mumps_project-build/libsmumpsd.a  _deps/mumps_project-build/libdmumpsd.a  _deps/mumps_project-build/libmumps_commond.a  /usr/local/lib/libscalapack.a  -lm  -ldl  -framework  Accelerate  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempif08.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_usempi_ignore_tkr.dylib  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi_mpifh.dylib  _deps/mumps_project-build/libpordd.a  /usr/local/Cellar/open-mpi/4.1.1_2/lib/libmpi.dylib && :
Undefined symbols for architecture x86_64:
  "_Cblacs_abort", referenced from:
      _PB_Cabort in libscalapack.a(PB_Cabort.c.o)
      _PB_Cmalloc in libscalapack.a(PB_Cmalloc.c.o)
  "_Cblacs_gridinfo", referenced from:
      _pstrsm_ in libscalapack.a(pstrsm_.c.o)
      _PB_Cabort in libscalapack.a(PB_Cabort.c.o)
      _PB_Cchkmat in libscalapack.a(PB_Cchkmat.c.o)
      _PB_Cplapad in libscalapack.a(PB_Cplapad.c.o)
      _PB_CptrsmAB in libscalapack.a(PB_CptrsmAB.c.o)
      _PB_CptrsmB in libscalapack.a(PB_CptrsmB.c.o)
      _PB_Cwarn in libscalapack.a(PB_Cwarn.c.o)
      ...
  "_Cblacs_pnum", referenced from:
      _PB_Cwarn in libscalapack.a(PB_Cwarn.c.o)
  "_Cigebr2d", referenced from:
      _psamax_ in libscalapack.a(psamax_.c.o)
  "_Cigebs2d", referenced from:
      _psamax_ in libscalapack.a(psamax_.c.o)
  "_Csgamx2d", referenced from:
      _psamax_ in libscalapack.a(psamax_.c.o)
  "_Csgebr2d", referenced from:
      _PB_Cstypeset in libscalapack.a(PB_Cstypeset.c.o)
      _psamax_ in libscalapack.a(psamax_.c.o)
      _psswap_ in libscalapack.a(psswap_.c.o)
  "_Csgebs2d", referenced from:
      _PB_Cstypeset in libscalapack.a(PB_Cstypeset.c.o)
      _psamax_ in libscalapack.a(psamax_.c.o)
      _psswap_ in libscalapack.a(psswap_.c.o)
  "_Csgerv2d", referenced from:
      _PB_Cstypeset in libscalapack.a(PB_Cstypeset.c.o)
      _psamax_ in libscalapack.a(psamax_.c.o)
      _psswap_ in libscalapack.a(psswap_.c.o)
  "_Csgesd2d", referenced from:
      _PB_Cstypeset in libscalapack.a(PB_Cstypeset.c.o)
      _psamax_ in libscalapack.a(psamax_.c.o)
      _psswap_ in libscalapack.a(psswap_.c.o)
  "_Csgsum2d", referenced from:
      _PB_Cstypeset in libscalapack.a(PB_Cstypeset.c.o)
  "_blacs_abort_", referenced from:
      _psgetf2_ in libscalapack.a(psgetf2.f.o)
      _pspotf2_ in libscalapack.a(pspotf2.f.o)
  "_blacs_gridexit_", referenced from:
      _smumps_end_driver_ in libsmumpsd.a(send_driver.F.o)
      _smumps_init_root_ana_ in libsmumpsd.a(stype3_root.F.o)
  "_blacs_gridinfo_", referenced from:
      _smumps_init_root_ana_ in libsmumpsd.a(stype3_root.F.o)
      _smumps_root_solve_ in libsmumpsd.a(ssol_root_parallel.F.o)
      _descinit_ in libscalapack.a(descinit.f.o)
      _psgetrs_ in libscalapack.a(psgetrs.f.o)
      _pspotrs_ in libscalapack.a(pspotrs.f.o)
      _chk1mat_ in libscalapack.a(chk1mat.f.o)
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      ...
  "_blacs_gridinit_", referenced from:
      ___smumps_save_restore_MOD_smumps_save_restore_structure in libsmumpsd.a(smumps_save_restore.F.o)
      _smumps_init_root_ana_ in libsmumpsd.a(stype3_root.F.o)
  "_igamn2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _psgetrf_ in libscalapack.a(psgetrf.f.o)
  "_igebr2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pslapiv_ in libscalapack.a(pslapiv.f.o)
      _psgetf2_ in libscalapack.a(psgetf2.f.o)
      _pslapv2_ in libscalapack.a(pslapv2.f.o)
      _pspotf2_ in libscalapack.a(pspotf2.f.o)
  "_igebs2d_", referenced from:
      _globchk_ in libscalapack.a(pchkxmat.f.o)
      _pslapiv_ in libscalapack.a(pslapiv.f.o)
      _psgetf2_ in libscalapack.a(psgetf2.f.o)
      _pslapv2_ in libscalapack.a(pslapv2.f.o)
      _pspotf2_ in libscalapack.a(pspotf2.f.o)
  "_igerv2d_", referenced from:
      _picol2row_ in libscalapack.a(picol2row.f.o)
      _pirow2col_ in libscalapack.a(pirow2col.f.o)
  "_igesd2d_", referenced from:
      _picol2row_ in libscalapack.a(picol2row.f.o)
      _pirow2col_ in libscalapack.a(pirow2col.f.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
[3118/4063] Building Fortran object external_src/oomph_flapack/CMakeFiles/oomph_flapack.dir/stzrzf.f.o
ninja: build stopped: subcommand failed.
scivision commented 3 years ago

after (to the right of) libscalapack.a there should be linked libblacs.a

scivision commented 3 years ago

sometimes libblacs.a is inside libscalapack.a, sometime not.

I will update FindScalapack.cmake to look for the optional libblacs.a

scivision commented 3 years ago

Here is a standalone MUMPS Cmake FetchContent example: https://github.com/scivision/mumps-fetchcontent

It works on my MacOS with:

% cmake -B build
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The Fortran compiler identification is GNU 11.1.0
puneetmatharu commented 3 years ago

Works an absolute treat -- thanks!