samedi 17 juin 2023

"error while loading shared libraries: libstdc.so.6" on a restricted CentOS machine when running a cross-compiled GCC

I have a restricted CentOS machine without GCC, make, package manager, and root access. I want to compile some software on this machine. Therefore, I decided to cross-compile a GCC on my personal computer. First, I compiled binutils-2.37 followed by gcc-10.3.0. The cross-compiling process was successful, and I transferred the resulting binaries to the restricted CentOS machine.

However, when I tried to run the GCC binary on the CentOS machine, I got this error: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory.

Here is the script i use to cross-compile my gcc.

...
# Step 3: Configure and compile Binutils
echo "Configuring and compiling Binutils..." | tee -a ${log_file}
cd binutils-${binutils_version}
mkdir -p ${output_dir}
./configure --prefix=${output_dir} --target=${your_target} &>> ${log_file}
make &>> ${log_file}
make install &>> ${log_file}
cd ..

# Step 4: Configure and compile GCC
echo "Configuring and compiling GCC..." | tee -a ${log_file}
cd gcc-${gcc_version}
export PATH=${output_dir}/bin:${PATH}
./contrib/download_prerequisites
./configure --prefix=${output_dir} --target=${your_target} --enable-languages=c,c++ --disable-multilib --disable-shared --enable-static
make all-gcc 
make install-gcc
...

What should I do to overcome this issue?

Aucun commentaire:

Enregistrer un commentaire