During setup on a specific set of servers, I need gcc-c++ installed to compile some of the software I am setting up. After install is complete I need to remove the compiler for security reasons. However, the libraries that gcc-c++ installs need to remain in place.

I can see the .so and .a files in the output of repoquery --list gcc-c++.

I could just copy those specific libraries to /tmp, run yum remove gcc-c++, and then move the libraries back into place.

Is there an already created solution to this? e.g. is there an option that yum or rpm has that would allow me to leave specific files from the package in place?

If no option in yum or rpm, is there any preferable way of doing it than my suggestion of copying to /tmp and moving them back afterward??

  • 1
    .a is never needed at runtime, and in gcc-c++ for CentOS6 (admittedly not the latest) the only .so I have is libstdc++. Runtime should not need that copy of libstdc++, but rather use the 'runtime' one installed by package libstdc++ in /usr/lib[64] – dave_thompson_085 Dec 12 '15 at 8:25
  • This is on RHEL 6, so that is helpful! Do you have a reference for the statement that packages should only need the /usr/lib copy of the libstdc++? (That reference could be exactly what I need to show the people I'm working with.) – Wildcard Dec 12 '15 at 19:40
  • 2
    No reference. Since "dynamic" (runtime) libs started being used, I think in OS/360 ca 1965, they have almost always been usable without compiletime tools so I just expect it. But it's easy to demo: just g++ helloworld.cpp -o helloworld; ldd helloworld and you see it's using /usr/lib[64] and not /usr/lib/gcc/$config/$ver/. Copy the executable to a machine (perhaps VM) with gcc and -devel NOT installed, and it works (libstdc++ runtime, like glibc for C, is in the base install). – dave_thompson_085 Dec 15 '15 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.