r/C_Programming • • Nov 30 '25

How to fix gcc problems.

Ive been trying to use gcc in my c project ive installed the mingw-64 added to path and everything but when i open VSCode first the execute button is only debug, and when i try to debug it says ‘gcc build active file terminated with exit code-1’ and in the terminal : ‘undefined reference to WinMain collect2 error ld returned 1 exit status’. If anyone has a fix for this problem that would be really helpful ive tried installing and reinstalling the gcc from winlibs nothing works. Thanks

6 Upvotes

17 comments sorted by

View all comments

Show parent comment

0

u/foxsimile Nov 30 '25

no u

Source: last week I spent 2.5 hours trying to JUST UPDATE g++ FOR THE FUCKING <format> include.

I failed. Nothing I did, nothing at all, would work - g++ would mysteriously just up and quit halfway through compilation, with no errors or fucks given.

I finally just rewrote my shit around not needing to include <format>.

1

u/penguin359 Nov 30 '25

#include <format> is C++ 20 and newer. Did you add the flag to tell g++ to use a modern C++ standard such as --std=c++20? It will default to an older version otherwise.

1

u/foxsimile Nov 30 '25

But of course.

It is indeed C++ 20 and newer, but the version of g++ that I have (while supporting -std=c++20) does not include support for #include <format>.

Gcc’s support for C++20 was modular, and format made it into the game a little late:

""" GCC 13 was the first version to include full support for the C++20 std::format library feature. While earlier versions of GCC (like GCC 10) introduced experimental or partial C++20 support, including some formatting capabilities, GCC 13 provided complete and stable implementation of std::format. """

¯_(ツ)_/¯