Duplicate symbol when linking core.so


#1

I have a strange problem with the latest psi4 (1.2a1.dev704 {master} a7fc050 1.1.0.999 1.1 <-- 1.2a1.dev704+a7fc050). I did specify the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER as llvm-gcc and llvm-g++. Any suggestions would be greatly appreciated.

duplicate symbol ___cpu_indicator_init in:
/usr/local/Cellar/gcc/7.2.0/lib/gcc/7/gcc/x86_64-apple-darwin16.7.0/7.2.0/libgcc.a(cpuinfo.o)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a(cpu_model.c.o)
duplicate symbol ___cpu_model in:
/usr/local/Cellar/gcc/7.2.0/lib/gcc/7/gcc/x86_64-apple-darwin16.7.0/7.2.0/libgcc.a(cpuinfo.o)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a(cpu_model.c.o)
duplicate symbol ___divtc3 in:
/usr/local/Cellar/gcc/7.2.0/lib/gcc/7/gcc/x86_64-apple-darwin16.7.0/7.2.0/libgcc.a(_divtc3.o)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a(divtc3.c.o)
ld: 3 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [src/core.so] Error 1
make[4]: *** [src/CMakeFiles/core.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [psi4-core-prefix/src/psi4-core-stamp/psi4-core-build] Error 2
make[1]: *** [CMakeFiles/psi4-core.dir/all] Error 2
make: *** [all] Error 2

Reinstalling xcode, clt, and gcc seems solve the problem.


#2

This error can also be caused by PCMSolver requesting gcc when you’re compiling with clang. In that case, the remedy is to set ENABLE_PCMSolver:BOOL=OFF in CMakeCache.txt.


#3

For future references, the problem is that I accidentally include the gcc directory to LD_LIBRARY_PATH which causes the confusions.