skip to Main Content

I want to run c++ on my centos machine. My Google searches says that run yum group install "Development Tools" command but this downloads other packages too like bison,perl,automake, etc which is not required for my use-case and only increases my docker container size. Can someone suggest the necessary packages required to run c++ ?
TIA

2

Answers


  1. The only necessary tool to "run" C++ (aka build C++) is a compiler:

    sudo yum install gcc
    echo "#include <iostream>" > main.cpp
    echo "int main(){ std::cout << "Hello World" << std::endl; }" >> main.cpp  
    gcc main.cpp -o test -lstdc++ 
    ./test  
    
    Login or Signup to reply.
  2. Sure, you can:

    sudo yum install gcc gcc-c++
    

    This will install default gcc version supplied by your distro.
    If you are on RHEL 7 and/or CentOS 7, the default gcc version is quite outdated (4.8.5), so you may want to install "devtoolset-N", which provide newer GCC versions, via Software Collections, for example look at this one. In there, in my experience, installing the devtoolset-N package will install the whole buch of stuff, similar to what groupinstall "Development Tools" does, so for Docker container it is good enough to only install devtoolset-N-toolchain. I also once needed devtoolset-N-libatomic-devel.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search