I’m currently using v2.6.2 of the Torizon IDE Extension for Visual Studio Code.
I noticed that some of the features of the standard library for C++ 20 are not supported even though __cplusplus is set to 202002 which would normally indicate C++ 20. For example I tried to use the time zone support in std::chrono::time_zone but that is not supported.
It looks like the container which the extension uses to build the code uses gcc v12.2.0.
and it appears that the newest version available is v13.3.1.
Is it possible to update the version of gcc used by the build container? Arm GNU Toolchain Downloads – Arm Developer
However, this page suggests that full support of C++ 20 might require gcc 14
So I might be out of luck for now if gcc 14 has not yet been ported to arm Compiler support for C++20 - cppreference.com
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
To address your issue with the C++20 support in the Torizon IDE Extension for Visual Studio Code, here are some steps and considerations:
Current GCC Version: As you mentioned, the current build container uses GCC v12.2.0. While this version does support many C++20 features, it may not fully support all of them, such as std::chrono::time_zone.
Updating GCC Version: You can attempt to update the GCC version in your build container. This involves creating a custom Dockerfile that installs the desired version of GCC. Here’s a basic example of how you might do this:
FROM torizon/debian-cross-toolchain-arm64:2-bullseye
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
wget \
&& rm -rf /var/lib/apt/lists/*
# Download and install GCC 13.3.1
RUN wget https://ftp.gnu.org/gnu/gcc/gcc-13.3.1/gcc-13.3.1.tar.gz \
&& tar -xzf gcc-13.3.1.tar.gz \
&& cd gcc-13.3.1 \
&& ./contrib/download_prerequisites \
&& mkdir build && cd build \
&& ../configure --enable-languages=c,c++ --disable-multilib \
&& make -j$(nproc) \
&& make install
# Set the new GCC as the default
RUN update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc 60 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++ 60
This Dockerfile starts from a base Torizon image and installs GCC 13.3.1. You can build this Dockerfile and use the resulting image as your build container.
Using the Custom Container in Torizon IDE:
In your VS Code project, update the devcontainer.json to use your custom Docker image.
Ensure that your project settings in the Torizon IDE extension point to this new container.
Limitations and Future Support: As you noted, full support for C++20 might require GCC 14, which may not yet be available for ARM. Keep an eye on updates from the GCC project and the Torizon team for newer toolchain support.
Alternative Libraries: If updating GCC does not resolve your issue, you might need to look for alternative libraries or workarounds. The date library you mentioned is a good fallback, but compatibility issues might arise with different GCC versions.
Community and Support: Engage with the Toradex community and support channels. Other developers might have faced similar issues and could offer solutions or workarounds.
By following these steps, you should be able to update the GCC version in your build container and potentially resolve the issues with C++20 support. If GCC 14 becomes available, you can follow a similar process to update to that version.
Please, also check if these links can help you solve your problem:
If you want another version of GCC you’ll need to customize the container with versions of things you require for your needs. Our containers are meant to be a starting point reference. They can always be customized for more specific needs. Have you tried substituting a different version of GCC to see if it fulfills your requirements?
I did try to use a newer version of GCC in the container, but I couldn’t figure out how to do it. So, I changed my strategy to avoid using the newer parts of the standard library. That means I am OK for now and I can just wait till the container we use is updated to the next version of Debian at some point in the future.
If you want to give me some pointers about how to use a newer version of GCC then I’d be happy to try it and report back.
If you want to give me some pointers about how to use a newer version of GCC then I’d be happy to try it and report back.
Well I’m not sure there’s any specific pointers really. A container is simply a sandbox environment. Building and installing a different version of gcc in a container would be a similar process to doing it on a non-container environment. There are generic instructions on installing gcc from their website here: Installing GCC - GNU Project
I imagine you would just need to do this process, but in a container. Now obviously Debian uses a specific version of gcc in it’s package feed for a reason. Venturing outside of these tested versions always has a “at your own risk” associated with it.
@jeremias.tx, I did try to follow those steps already but I encountered errors while attempting to build gcc in the container. At that point I decided it probably wasn’t worth going further down this path as I can work around the library limitations. I think we can close this ticket.
Hey @MikeS,
I tried it locally (I use a newer GCC from time to time due to C++ support as well) and following the GNU Project instructions it worked well. Note that it can take a while to build.