xtb icon indicating copy to clipboard operation
xtb copied to clipboard

Duplicate symbols: MacOS build with ifort and clang compilers

Open TyBalduf opened this issue 3 years ago • 3 comments

Describe the bug On Mac (I don't think its version specific, but I have at least seen it on 11.6), when I try to build using the ifort_2022 Fortran compiler and Apple clang 13.0.0 C-compiler, I get a duplicate symbols error while trying to build.

This does not occur for me on Linux (using gcc C compiler) or Window (MSVC C compiler). I'm curious to see if this is a real issue with this combination of compilers or if something is wrong with my specific build set up.

meson input meson setup xtb build --buildtype=release -Dla_backend=mkl-rt -Dopenmp=false -Dfortran_args=-fpp

Relevant section of output

[stdout] [381/415] Compiling Fortran object libxtb.6.dylib.p/src_bias_path.f90.o
[stdout] [382/415] Linking target libxtb.6.dylib
[stdout] [383/415] Linking static target libxtb.a

[stdout] [384/415] Linking target test/api/xtb_c_test
[stdout] FAILED: test/api/xtb_c_test
[stdout] /bin/clang  -o test/api/xtb_c_test test/api/xtb_c_test.p/c_api_example.c.o -L/software/lib/Darwin-x86_64/ifort_2022.0.0/compiler/lib -L/software/lib/Darwin-x86_64/ifort_2020.0.166/mkl/lib -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error libxtb.a subprojects/mctc-lib/libmctc-lib.a subprojects/json-fortran-8.2.5/libjsonfortran.a -lifcore -lmkl_rt -lsvml -lirc -lifcore -lmkl_rt -lsvml -lirc -limf
[stdout] duplicate symbol '_json_parameters._' in:
[stdout]     libxtb.a(src_json_parameters.F90.o)
[stdout]     subprojects/json-fortran-8.2.5/libjsonfortran.a(src_json_parameters.F90.o)
[stdout] duplicate symbol '_json_parameters_mp_control_chars_' in:
[stdout]     libxtb.a(src_json_parameters.F90.o)
[stdout]     subprojects/json-fortran-8.2.5/libjsonfortran.a(src_json_parameters.F90.o)
[stdout] ld: 2 duplicate symbols for architecture x86_64
[stdout] clang: error: linker command failed with exit code 1 (use -v to see invocation)

[stdout] [385/415] Compiling Fortran object xtb.p/src_prog_submodules.f90.o
[stdout] [386/415] Compiling Fortran object xtb.p/src_prog_argparser.f90.o
[stdout] [387/415] Compiling Fortran object test/unit/tester.p/test_atomlist.f90.o
[stdout] [388/415] Compiling Fortran object test/unit/tester.p/molstock.f90.o
[stdout] [389/415] Compiling Fortran object test/unit/tester.p/test_coordinationnumber.f90.o
[stdout] [390/415] Compiling Fortran object test/unit/tester.p/test_dftd3.f90.o
[stdout] [391/415] Compiling Fortran object test/unit/tester.p/test_dftd4.f90.o
[stdout] [392/415] Compiling Fortran object test/unit/tester.p/test_eeq.f90.o
[stdout] [393/415] Compiling Fortran object test/unit/tester.p/test_coulomb.f90.o
[stdout] ninja: build stopped: subcommand failed.

Note this fails while building xtb_c_test, but if I manually remove subdir('test') from the end of meson.build, it will also fail with the same duplicated symbols error while linking for the xtb executable.

TyBalduf avatar Aug 30 '22 20:08 TyBalduf

You could remove the JSON support from the IO library using -Dmctc-lib:json=disabled which apparently cases issues due to duplicated symbols here or try to build either mctc-lib or json-fortran as shared library using -Dmctc-lib:default_library=shared / -Djson-fortran-8.2.5:default_library=shared.

awvwgk avatar Aug 30 '22 20:08 awvwgk

For MacOS builds you can also check https://github.com/grimme-lab/homebrew-qc, which provides homebrew compatible build instructions.

awvwgk avatar Aug 30 '22 20:08 awvwgk

@awvwgk Disabling JSON supports seems to have done the trick. Thank you!

TyBalduf avatar Aug 31 '22 16:08 TyBalduf