0

This is centos system. I has installed intel HPC toolkit(toolkit before intel oneAPI, including intel c++/c/fortran/MKL...). Then after I remove the intel toolkit, my g++ didn't work(so does my gcc, same error). It seems the g++ is looking for intel math library. Since I removed the intel toolkit, it can not find the intel math library and complain error.

How can I tell g++ do not to find intel math library? And how can I know what library g++ are looking for?

Thank you for your help!


The c++ example

#include<iostream>                                                                                                     #include<cmath>
   int main(){
     int a = 1<<31;
     std::cout<<"a is "<< a <<std::endl;
     int b = std::abs(a);
     std::cout<<"b is "<< b <<std::endl;
     return 0;
   }

the command I used to compile the c++ example

g++ a.cpp

the error it complain

/usr/local/gcc/10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/cc1plus: error while loading shared libraries: libsvml.so: cannot open shared object file: No such file or directory

LDD result: for my gcc

(base) [Js@XiaoXin13pro ~]$ ldd  /usr/local/gcc/10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/cc1plus
        linux-vdso.so.1 =>  (0x00007fffffad5000)
        libisl.so.15 => /usr/local/lib/libisl.so.15 (0x00007f111d980000)
        libmpc.so.3 => /usr/local/lib/libmpc.so.3 (0x00007f111d760000)
        libmpfr.so.4 => /usr/local/lib/libmpfr.so.4 (0x00007f111d4f0000)
        libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007f111d260000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f111d040000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f111cd30000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f111c960000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f111de00000)
        libimf.so => /lib64/libimf.so (0x00007f111c490000)
        libsvml.so => not found
        libirng.so => not found
        libgcc_s.so.1 => /usr/local/gcc/10.1.0/lib64/libgcc_s.so.1 (0x00007f111c260000)
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libintlc.so.5 => not found

LDD result: for system gcc

(base) [Js@XiaoXin13pro ~]$ ldd /usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1plus
        linux-vdso.so.1 =>  (0x00007fffea241000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f225a4e0000)
        libmpc.so.3 => /usr/local/lib/libmpc.so.3 (0x00007f225a2c0000)
        libmpfr.so.4 => /usr/local/lib/libmpfr.so.4 (0x00007f225a050000)
        libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007f2259dc0000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f2259b90000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f2259880000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f22594b0000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f225a800000)
        libimf.so => /lib64/libimf.so (0x00007f2258fe0000)
        libsvml.so => not found
        libirng.so => not found
        libgcc_s.so.1 => /usr/local/gcc/10.1.0/lib64/libgcc_s.so.1 (0x00007f2258db0000)
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libintlc.so.5 => not found

update gcc using scl:

sudo yum install centos-release-scl
sudo yum install devtoolset-8-gcc*
scl enable devtoolset-8 bash

check gcc

(base) [Js@XiaoXin13pro ~]$ which gcc
/opt/rh/devtoolset-8/root/usr/bin/gcc
(base) [Js@XiaoXin13pro ~]$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and still complain

(base) [Js@XiaoXin13pro ~]$ g++ a.cpp
/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/cc1plus: error while loading shared libraries: libsvml.so: cannot open shared object file: No such file or directory

and ldd result

(base) [Js@XiaoXin13pro ~]$ ldd /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/cc1plus
        linux-vdso.so.1 =>  (0x00007ffff5a56000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fe19add0000)
        libmpc.so.3 => /usr/local/lib/libmpc.so.3 (0x00007fe19abb0000)
        libmpfr.so.4 => /usr/local/lib/libmpfr.so.4 (0x00007fe19a940000)
        libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007fe19a6b0000)
        libz.so.1 => /lib64/libz.so.1 (0x00007fe19a480000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fe19a170000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fe199da0000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fe19b000000)
        libimf.so => /lib64/libimf.so (0x00007fe1998d0000)
        libsvml.so => not found
        libirng.so => not found
        libgcc_s.so.1 => /usr/local/gcc/10.1.0/lib64/libgcc_s.so.1 (0x00007fe1996a0000)
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libsvml.so => not found
        libirng.so => not found
        libintlc.so.5 => not found
        libintlc.so.5 => not found
  • The GCC install you're running is apparently in `/usr/local/gcc/`, so that's some custom GCC install in your `$PATH`, not the system GCC on whatever system you have. The error message says it was looking for `libsvml.so`. (Apparently while executing the compiler itself, not trying to link the compiler output with it.) Use `ldd` to check library dependencies on executables. – Peter Cordes Nov 30 '21 at 07:36
  • @PeterCordes Yes, that is GCC compiled by myself. I try ldd and find it seems do not depend on intel library? I have updated ldd's result in the post. – Runfeng Jin Nov 30 '21 at 11:22
  • You ran `ldd` on the `g++` front-end command, not the `cc1plus` C++ compiler proper that it invokes if you run it on a `.cpp` file (instead of on a `.o` or `.s` file for example). The error message included the path `/usr/local/gcc/10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/cc1plus` as the executable that couldn't find its library dependency. If run `g++ -v foo.cpp` you can see what other programs the front-end invokes. – Peter Cordes Nov 30 '21 at 11:28
  • @PeterCordes WOW! got it! I try ldd with both my cc1plus and system's cc1plus . And seems both them looking for some intel's libraries. How can I tell them do not find intel's library? I have update ldd 's result in post. – Runfeng Jin Nov 30 '21 at 11:44
  • Are any of those system directories (or the files) a symlink to /usr/local/...? Maybe you messed up (or moved aside) your system GCC at some point. Because that's definitely not normal. GCC4.8.5 is pretty old at this point anyway, might as well upgrade to a new GCC anyway (or a whole new distro version). Or just reinstall the distro packages that are supposed to provide those GCC files. – Peter Cordes Nov 30 '21 at 11:53
  • Apparently `/usr/local/gcc/10.1.0/lib64/libgcc_s.so.1` is in the ld search path somehow? That's weird, I wouldn't expect that directory to be in the path, and certainly the system GCC wouldn't have that path embedded in it unless it's been replaced. – Peter Cordes Nov 30 '21 at 11:55
  • @PeterCordes Hi! I install gcc 8.3.1 using scl. And it encouters same error. And its ldd result seems to find intel library, too. That's really a weird thing!? – Runfeng Jin Nov 30 '21 at 12:21
  • The "scl gcc/g++" assumes that the system compilers are installed. When no system gcc-c++, it seems that "gcc 8.3.1" is using files from the gcc built with the intel math library. – Knud Larsen Nov 30 '21 at 14:04
  • @KnudLarsen Can I tell gcc to not to search intel math library? – Runfeng Jin Dec 01 '21 at 07:50
  • 1. Install the system compiler `gcc-c++` . ... 2. Delete `/usr/local/gcc/10.1.0` ........ and build a new gcc10 https://drive.google.com/file/d/1zIwm4j1obAPYbQqva9LDNMrvCpR39sgu/view?usp=sharing .... Other "extra gcc" https://stackoverflow.com/questions/47175706/how-to-install-gcc-4-9-2-on-rhel-7-4/47189915#47189915 – Knud Larsen Dec 01 '21 at 09:59
  • @KnudLarsen I remove system gcc and g++ by yum, and I delete the gcc10 folder, And then I reinstall gcc4.8.5. But the same error emerges. It seems some places should be changed? – Runfeng Jin Dec 05 '21 at 04:14

1 Answers1

0

I find someone encountered the same error. It's shown in here Install OpenMPI from repository with GCC instead of Intel.

Why gcc is looking for the intel math library? In my exampl, it seems mpc\mpfr\gmp in /usr/local/lib depends on the Intel library.

I searched these three library in other path but found nothing. I removed these three library and reinstalled gcc by sudo yum install gcc. And this time it works fine.

The last time I reinstalled gcc and failed, because yum find these three library in /usr/local/lib and didn't reinstall them. So the reinstalled gcc that depends on the library still will search for Intel math library. And this time since the library in /usr/local/lib is removed, yum install these three library that don't depend on Intel math library. So gcc don't search for intel math library anymore.

I guess maybe these libraries in /usr/local/lib is installed when I install my gcc10 and that time Intel library is still in there, so these libraries are builed with intel and depend on intel library.


By the way, this post explains what is mpc\mpfr\gmp :

GCC depends on:
GMP: GNU Multiple Precision Arithmetic Library
MPFR: GNU Multiple-precision floating-point rounding library
MPC: GNU Multiple-precision C library
ELF: Executable and Linkable Format library
PPL: Parma Polyhedra Library (optional, for memory optimizations)