[petsc-dev] [petsc-maint] problems compiling petsc on MAC

Barry Smith bsmith at mcs.anl.gov
Mon May 1 15:27:17 CDT 2017


  Is there are reason to have the same symbol in both library (note they come from the fortran versions)

$ nm -o arch-uni-f2cblaslapack/lib/libf2cblas.a | grep xerbla | grep " T "
arch-uni-f2cblaslapack/lib/libf2cblas.a:xerbla_array.o: 0000000000000000 T _xerbla_array_
arch-uni-f2cblaslapack/lib/libf2cblas.a:xerbla.o: 0000000000000000 T _xerbla_
~/Src/petsc (next=) arch-basic
$ nm -o arch-uni-f2cblaslapack/lib/libf2clapack.a | grep xerbla | grep " T "
arch-uni-f2cblaslapack/lib/libf2clapack.a:xerbla_array.o: 0000000000000000 T _xerbla_array_
arch-uni-f2cblaslapack/lib/libf2clapack.a:xerbla.o: 0000000000000000 T _xerbla_

  Should we remove them?

> On May 1, 2017, at 2:21 PM, andrea lani <andrea.lani at gmail.com> wrote:
> 
> 
>>> Hello,
>>> 
>>> While trying to compile my code using static linking, I have stumbled into some troubles on my Mac. I have two questions:
>>> 
>>> 1) if I compile petsc with 
>>> 
>>> ./configure --prefix=/Users/lani/COOLFluiD/deps/mpich/petsc_long_fortran --with-debugging=0 --with-64-bit-indices FFLAGS=-O3  F90FLAGS=-O3  CFLAGS=-O3  CXXFLAGS=-O3  CXXOPTFLAGS=-O3  COPTFLAGS=-O3  FOPTFLAGS=-O3  --with-mpi-dir=/Users/lani/COOLFluiD/deps/mpich --download-f2blaslapack=1 --with-fortran=0 --with-shared-libraries=0   --PETSC_ARCH=arch-darwin
>>> 
>>> in which folder are liblapack.a and libblas.a created? After a successful petsc installation, I cannot find them anywhere, but I actually need the path to them: my numerical solver, when linked statically  
>>> to petsc,  fails at the need of compilation with undefined references precisely to lapack/blas functions.  
>>> 
>>> If I use --download-f2cblaslapack=1 , libf2cblas.a  and  libf2clapack.a are created and installed correctly, but then I am still left with a undefined reference to  “xerbla_array” which is defined in libf2cblas.a but not found even though I explicitly link to it.
>> 
>>  Hmm, works for me.
>> 
>> $ ls arch-uni-f2cblaslapack/lib/
>> libf2cblas.a   libf2clapack.a libpetsc.a     petsc          pkgconfig
>> 
>> $ cat > joe.F90
>> 
>>       program main
>>       call xerbla_array(1)
>>       return 
>>       end
>> ~/Src/petsc (maint=) arch-uni-f2cblaslapack
>> $ gfortran joe.F90 -L./arch-uni-f2cblaslapack/lib -l f2cblas
>> ~/Src/petsc (maint=) arch-uni-f2cblaslapack
>> $ ./a.out
>> ** On entry to       , parameter number 183283211 had an illegal value
>> it could find the symbol, just crashed because I didn't call the routine properly. Does this test work for you?
>> 
>> Barry
> 
> Hi Barry,
> 
> I would say that this simple example compiles and links fine, I get no undefined references, which is my original problem.  
> When I run it I get some error, but that’s not my problem right now.
> 
> 
> gfortran joe.F90 /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long_clang/lib/libf2cblas.a /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long_clang/lib/libf2clapack.a
> 
> 
> 
> But this is what happens in my real-life case (which goes through a pretty involved cmake building system): actually by rearranging the order of the libraries to which libpetsc.a links and putting libf2clapack and libf2cblas first I now get a duplicated symbol _xerbla_array_ instead of undefined reference. Better, but still to there. 
> 
> 
> [100%] Linking CXX executable coolfluid-solver
> cd /Users/lani/TRUNK/MPICH_MF_STATIC_CLANG/optim/apps/Solver && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/coolfluid-solver.dir/link.txt --verbose=1
> /Users/lani/COOLFluiD/deps/mpich/bin/mpic++    -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/coolfluid-solver.dir/coolfluid-solver.cxx.o  -o coolfluid-solver -all_load  /Users/lani/COOLFluiD/deps/mpich/lib/libmpi.a ../../src/logcpp/liblogcpp.a ../../src/Common/libCommon.a ../../src/Config/libConfig.a ../../src/Environment/libEnvironment.a ../../src/MathTools/libMathTools.a ../../src/Framework/libFramework.a ../../src/ShapeFunctions/libShapeFunctions.a ../../plugins/AnalyticalModel/libAnalyticalModel.a ../../plugins/CFmeshExtruder/libCFmeshExtruder.a ../../plugins/CFmeshFileReader/libCFmeshFileReader.a ../../plugins/CFmeshFileWriter/libCFmeshFileWriter.a ../../plugins/FiniteVolume/libFiniteVolume.a ../../plugins/FiniteVolumeMHD/libFiniteVolumeMHD.a ../../plugins/FiniteVolumeMaxwell/libFiniteVolumeMaxwell.a ../../plugins/FiniteVolumeMultiFluidMHD/libFiniteVolumeMultiFluidMHD.a ../../plugins/ForwardEuler/libForwardEuler.a ../../plugins/Gambit2CFmesh/libGambit2CFmesh.a ../../plugins/Gmsh2CFmesh/libGmsh2CFmesh.a ../../plugins/MHD/libMHD.a ../../plugins/Maxwell/libMaxwell.a ../../plugins/MultiFluidMHD/libMultiFluidMHD.a ../../plugins/NewtonMethod/libNewtonMethod.a ../../plugins/ParaViewWriter/libParaViewWriter.a ../../plugins/Petsc/libPetscI.a ../../plugins/THOR2CFmesh/libTHOR2CFmesh.a ../../plugins/Tecplot2CFmesh/libTecplot2CFmesh.a ../../plugins/TecplotWriter/libTecplotWriter.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_thread.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_filesystem.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_system.a ../../plugins/FiniteVolume/libFiniteVolume.a ../../src/ShapeFunctions/libShapeFunctions.a ../../plugins/Maxwell/libMaxwell.a /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long_clang/lib/libpetsc.a /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long/lib/libf2clapack.a /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long/lib/libf2cblas.a /opt/local/lib/libiconv.a /opt/local/lib/libXdmcp.a /opt/local/lib/liblzma.a /opt/local/lib/libz.a /opt/local/lib/liblzo2.a /opt/local/lib/libXau.a /opt/local/lib/libbz2.a /opt/local/lib/liblz4.a /opt/local/lib/libxcb.a /opt/local/lib/libxml2.a /opt/local/lib/libarchive.a /opt/local/lib/libcrypto.a /opt/local/lib/libssl.a /opt/local/lib/libX11.a ../../src/Framework/libFramework.a ../../src/Environment/libEnvironment.a ../../src/Config/libConfig.a ../../src/MathTools/libMathTools.a ../../src/Common/libCommon.a ../../src/logcpp/liblogcpp.a /Users/lani/COOLFluiD/deps/mpich/lib/libmpi.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_thread.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_filesystem.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_system.a -ldl /Users/lani/COOLFluiD/deps/mpich/lib/libparmetis.a /Users/lani/COOLFluiD/deps/mpich/lib/libmetis.a 
> duplicate symbol _xerbla_array_ in:
>     /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long/lib/libf2clapack.a(xerbla_array.o)
>     /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long/lib/libf2cblas.a(xerbla_array.o)
> duplicate symbol _xerbla_ in:
>     /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long/lib/libf2clapack.a(xerbla.o)
>     /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long/lib/libf2cblas.a(xerbla.o)
> ld: 2 duplicate symbols for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
> make[2]: *** [apps/Solver/coolfluid-solver] Error 1
> make[1]: *** [apps/Solver/CMakeFiles/coolfluid-solver.dir/all] Error 2
> make: *** [all] Error 2
> 
> 
> Why is this link duplicated? Why don’t I get the same for the gfortran example above? can I force the clang++ linker to ignore this?
> I attach the full log file of the compilation (error.log) and the configure.log corresponding to petsc building. 
> 
> 
> 
> 
> I have also tried to re-link coolfluid-solver using a slightly modified version of the link command:
> 
> /Users/lani/COOLFluiD/deps/mpich/bin/mpic++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-multiply_defined,suppress  CMakeFiles/coolfluid-solver.dir/coolfluid-solver.cxx.o  -o coolfluid-solver -all_load  /Users/lani/COOLFluiD/deps/mpich/lib/libmpi.a ../../src/logcpp/liblogcpp.a ../../src/Common/libCommon.a ../../src/Config/libConfig.a ../../src/Environment/libEnvironment.a ../../src/MathTools/libMathTools.a ../../src/Framework/libFramework.a ../../src/ShapeFunctions/libShapeFunctions.a ../../plugins/AnalyticalModel/libAnalyticalModel.a ../../plugins/CFmeshExtruder/libCFmeshExtruder.a ../../plugins/CFmeshFileReader/libCFmeshFileReader.a ../../plugins/CFmeshFileWriter/libCFmeshFileWriter.a ../../plugins/FiniteVolume/libFiniteVolume.a ../../plugins/FiniteVolumeMHD/libFiniteVolumeMHD.a ../../plugins/FiniteVolumeMaxwell/libFiniteVolumeMaxwell.a ../../plugins/FiniteVolumeMultiFluidMHD/libFiniteVolumeMultiFluidMHD.a ../../plugins/ForwardEuler/libForwardEuler.a ../../plugins/Gambit2CFmesh/libGambit2CFmesh.a ../../plugins/Gmsh2CFmesh/libGmsh2CFmesh.a ../../plugins/MHD/libMHD.a ../../plugins/Maxwell/libMaxwell.a ../../plugins/MultiFluidMHD/libMultiFluidMHD.a ../../plugins/NewtonMethod/libNewtonMethod.a ../../plugins/ParaViewWriter/libParaViewWriter.a ../../plugins/Petsc/libPetscI.a ../../plugins/THOR2CFmesh/libTHOR2CFmesh.a ../../plugins/Tecplot2CFmesh/libTecplot2CFmesh.a ../../plugins/TecplotWriter/libTecplotWriter.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_thread.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_filesystem.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_system.a ../../plugins/FiniteVolume/libFiniteVolume.a ../../src/ShapeFunctions/libShapeFunctions.a ../../plugins/Maxwell/libMaxwell.a /Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long_clang/lib/libpetsc.a ../../src/Framework/libFramework.a ../../src/Environment/libEnvironment.a ../../src/Config/libConfig.a ../../src/MathTools/libMathTools.a ../../src/Common/libCommon.a ../../src/logcpp/liblogcpp.a /Users/lani/COOLFluiD/deps/mpich/lib/libmpi.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_thread.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_filesystem.a /Users/lani/COOLFluiD/deps/mpich/boost/lib/libboost_system.a -ldl /Users/lani/COOLFluiD/deps/mpich/lib/libparmetis.a /Users/lani/COOLFluiD/deps/mpich/lib/libmetis.a -Wl,-rpath,/Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long_clang/lib -L/Users/lani/COOLFluiD/deps/mpich/petsc_3.7.6_long_clang/lib -Wl,-rpath,/opt/X11/lib -L/opt/X11/lib -Wl,-rpath,/Users/lani/COOLFluiD/deps/mpich/lib -L/Users/lani/COOLFluiD/deps/mpich/lib -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/6.0/lib/darwin -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin  -lclang_rt.osx -lf2clapack -lf2cblas -lX11 -lssl -lcrypto -lmpich -lpthread -lclang_rt.osx -lmpicxx -lc++ -ldl -lgcc_s.1 -lmpi -lpmpi -lSystem -lclang_rt.osx -ldl -lgcc_s.1
> 
> incorporating the content of the PETSC_EXTERNAL_LIB_BASIC taken from petsc-3.7.6/arch-darwin/lib/petsc/conf/petscvariables  (also attached), but changes nothing.
> 
> Thanks for any suggestion you might have… 
> Best
> 
> Andrea
> 
> 
> 
> 
> 
> 
> 
> 
> <error.log><configure.log><petscvariables>




More information about the petsc-dev mailing list