Skip to content

ld: library not found for -lgfortran MacOS, clang + ifort compilers #2311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BarrySmith opened this issue Nov 19, 2019 · 7 comments · Fixed by #3185
Closed

ld: library not found for -lgfortran MacOS, clang + ifort compilers #2311

BarrySmith opened this issue Nov 19, 2019 · 7 comments · Fixed by #3185

Comments

@BarrySmith
Copy link

f_check has

if ($vendor eq "INTEL"){
    $linker_a .= "-lgfortran"
}

I don't even have GNU compilers on my machine.

If I remove these lines then I get

mpif90 -O2 -fPIC  -all_load -headerpad_max_install_names -install_name "/Users/barrysmith/Src/petsc/arch-maint/externalpackages/git.openblas/exports/../libopenblas.0.dylib" -dynamiclib -o ../libopenblas_haswellp-r0.3.8.dev.dylib ../libopenblas_haswellp-r0.3.8.dev.a -Wl,-exported_symbols_list,osx.def  -L/Users/barrysmith/soft/clang-ifort/lib -L/Users/barrysmith/soft/clang-ifort/lib -Wl,-rpath,/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib -L/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib -L/usr/lib  -lmpifort -lmpi -lpmpi -lmpifort -lmpi -lpmpi -lSystem -lpthread  /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libifport.a /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libifcoremt.a /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libimf.a /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libsvml.a /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libipgo.a /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libirc.a /opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/libsvml.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.osx.a 
make[1]: Leaving directory '/Users/barrysmith/Src/petsc/arch-maint/externalpackages/git.openblas/exports'Undefined symbols for architecture x86_64:
  "_MAIN__", referenced from:
      _main in libifcoremt.a(for_main.o)
  "__FTN_ALLOC", referenced from:
      _do_ftn_alloc in libifcoremt.a(for_ftnalloc.o)
ld: symbol(s) not found for architecture x86_64
make[1]: *** [Makefile:123: libopenblas_haswellp-r0.3.8.dev.dylib] Error 1

The problem is that you are not stripping out the libifcoremt.a library so the resulting list cannot be used to make a dynamic library

Mac OS 10.14.6
ifort version 19.0.4.233
Apple clang version 11.0.0 (clang-1100.0.33.12)

@xianyi
Copy link
Collaborator

xianyi commented Nov 19, 2019

How do you compile the library?

make CC=clang FC=ifort?

@martin-frbg
Copy link
Collaborator

This may be related to #1956 (and changes I made in response to that issue.). But yes more details of how you are building OpenBLAS (cmake or make ?) would be helpful.

@martin-frbg
Copy link
Collaborator

BTW that strange-looking conditional was added by xianyi some eight years ago, possibly to accomodate builds that included a prebuilt netlib LAPACK. I do not think it can hurt as long as the Intel libraries take precedence. Possibly there is a -shared argument missing somewhere that would tell it to skip the static version of the multithreading library.

@BarrySmith
Copy link
Author

 make CC=mpicc FC=mpif90  MAKE_NB_JOBS=13  USE_OPENMP=0  USE_THREAD=1  NO_EXPRECISION=1   libs netlib re_lapack shared 
$ mpif90 -show
ifort -g -Wl,-flat_namespace -Wl,-commons,use_dylibs -I/Users/barrysmith/soft/clang-ifort/include -I/Users/barrysmith/soft/clang-ifort/include -L/Users/barrysmith/soft/clang-ifort/lib -lmpifort -lmpi -lpmpi
~/Src/petsc (maint *=) 

@martin-frbg
Copy link
Collaborator

Any reason why you specifiy only select subtargets to make ? Not sure if that could circumvent or counteract parts of the normal build process (which is not particularly pretty). BTW you can set BUILD_RELAPACK=1 (or change the defaults in Makefile.rule) if you want ReLAPACK included, but beware it may not yet pass all the stock LAPACK tests.

@brada4
Copy link
Contributor

brada4 commented Nov 19, 2019

Could you confirm compilation with ifort and clang (or icl) and then add parts one by one until they fail?

@brada4
Copy link
Contributor

brada4 commented Nov 19, 2019

Here some barf over google lines:
https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/494782
xcode 11.2(.0 or .1) is not yet in any intel's compatibilty lists. Probably check with them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants