CHINMAY ANAND.S
CHINMAY ANAND.S

Reputation: 1

How do I install the latest version of gcc(13.2.0) in a dev container with image suse/sle15:15.2?

I am trying to run a c++ program on a dev container(docker container). I have attached VS code to that container. The docker container is running SUSE SLES15 SP2. (image: registry.suse.com/suse/sle15:15.2) This is the program:

#include <iostream>
#include <filesystem>

int main() {
    // Print "Hello, World!"
    std::cout << "Hello, World!" << std::endl;

    // Example filesystem operations
    std::filesystem::path currentPath = std::filesystem::current_path();
    std::cout << "Current path: " << currentPath << std::endl;
    return 0;
}

A fairly simple program that uses the std cpp 17 library filesystem

But now the gcc complains that there is no such file or directory.

/home/developer/workspace/rough # g++ hello.cpp
hello.cpp:2:10: fatal error: filesystem: No such file or directory
 #include <filesystem>
          ^~~~~~~~~~~~
compilation terminated.

When I check the gcc --version it says

/home/developer/workspace/rough # gcc --version
gcc (SUSE Linux) 7.5.0
Copyright (C) 2017 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.

Now I do know that the gcc version is an older version and hence the filesystem does not exist. (I also do not want to use experimental/filesystem)

How do I update the gcc version in this case?

I have tried the following: I have tried to update gcc version by running zypper update. But this does not update the gcc version.

I tried to install the latest version of gcc using homebrew. I was able to download the latest version but after I add the PATH to the latest gcc in .bashrc, It would still point to 7.5.0. How do I update this?

Upvotes: 0

Views: 687

Answers (1)

datawookie
datawookie

Reputation: 6564

I don't have license for SUSE but you can do this with a recent version of OpenSUSE.

FROM opensuse/tumbleweed

RUN zypper update -y && \
    zypper install -y gcc-c++

COPY hello.cpp .

RUN g++ hello.cpp -o hello

CMD ./hello

enter image description here

Upvotes: 0

Related Questions