Can't find libstdc++.a in CentOs

When writing code, sometimes it is necessary to statically link the libstdc++.a library, but there are cases where only the dynamic library of libstdc++.so does not have the libstdc++.a static library.

First run the command to check whether the libstdc++.a static library exists in the system.

find / -name libstdc++.a

If it does not exist, you can use the following command to find the name of the package containing the libstdc++.a file

sudo dnf provides '*/libstdc++.a'

Obtain libstdc++.a by installing a package that includes the libstdc++.a file, so that it does not need to be obtained through source code compilation.

sudo dnf install gcc-toolset-12-libstdc++-devel

Run the command again after installation to find the location of the libstdc++.a file.

find / -name libstdc++.a

Finally, the files will be copied to the /usr/lib64 directory, which will be automatically searched during static linking.

cd /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
cp ./libstdc++.a /usr/lib64

Guess you like

Origin blog.csdn.net/weixin_43074760/article/details/131616272