Cmake build error for cmake_example in FreeRTOSv202604.00-LTS

I have downloaded and extracted FreeRTOSv202604.00-LTS and FreeRTOSv202406.05-LTS from freertosORG.
In both versions, I tried to build cmake_example (\FreeRTOS-LTS\FreeRTOS\FreeRTOS-Kernel\examples\cmake_example\) using the following commands at the given location.

1) mkdir build
2) cd build
3) cmake ..
4) cmake --build .

For v2024 it builds clean and creates \build\Debug\example.exe
However, for v2026 it throws the error for the command cmake --build .

I have attached an error window snapshot in this message. Please help me resolve this issue. Is there any problem with latest version of FreeRTOS?

This looks like a toolchain setup error. Somewhere under the hood your cmake is using an MSVC compiler rather than a GCC/Clang compiler. This explains why certain syntax like __attribute__ is not being recognized.

You’re going to need to use a GCC-compatible toolchain. You might be able to force this with the cmake -G "MinGW Makefiles" .. parameter.

Hi Kody,
Thank you very much for your response.
I’m new to FreeRTOS and have just started exploring it by compiling example projects to understand how it works. Your reply genuinely means a lot to me.

I tried using the commands in the given sequence, but I still get some different errors. (This time, the error appears in both v2024 and v2026.)

  1. cmake -G “MinGW Makefiles” ..

  2. mingw32-make or **cmake --build .
    **
    But now I am getting errors like: integer constant is too large for ‘unsigned long’ type [-Werror=long-long]. (error snapshot given below)
    I tried to check event_groups.c 197 and tried to see where the variable data type is originally defined, but everything looks fine there. I do not need to make changes to the files; instead, I need to find out if I am using 64-bit compilers. So, I tried using the following commands, but the error persists.

  3. **cmake -G “MinGW Makefiles” -DCMAKE_MAKE_PROGRAM=C:/mingw64/bin/mingw32-make.exe -DCMAKE_C_COMPILER=C:/mingw64/bin/x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER=C:/mingw64/bin/x86_64-w64-mingw32-g++.exe ..
    **
    So my question is, if I downloaded FreeRTOS from FreeRTOS-ORG, i.e., a fresh download without any changes, one with version v2024 and another with version v2026(using commands cmake .. and cmake --build .), why does it work on v2024 and not on v2026?

I mean, is there any fix needed for v2026?

This seems to come down to building on Windows. Windows defines a long as a 32-bit value even on a 64-bit OS. Many 64-bit Linux distros define a long as a 64-bit value.

The issue arises when you define the tick size to 64 bits. On windows this requires an unsigned long long which requires a compiler newer than C90. The standard is enforced here in the CMake file.

To get around this you could try changing this line in your local copy of the template config to #define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS

If this ends up working, let me know. I’m happy to update the code to default to a 32-bit tick so that windows builds happily.

To get a complete list of warnings at one go, you can comment out this line so that warnings are not treated as errors and then we can take a look what all needs to be changed.

Hi Kody,
Thanks for your response.

As you suggested, I changed line 139 (FreeRTOSConfig.h) in my local copy of the template config to
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS and run the commands below.

1) mkdir build
2) cd build
3) cmake -G "MinGW Makefiles" ..
4) mingw32-make

This worked out for me. I can see example.exe get created(snapshot attached). This is true for both versions, v2024 and v2026. (Additionally, I checked CLI outputs and found the compiler info “The C compiler identification is GNU 15.2.0”.)

Regards,
Akshay

Hi Gaurav,
Thank you very much for your response.

As you suggested, I commented line 57 (CMakeLists.txt) and ran the commands below.

1) mkdir build
2) cd build
3) cmake -G "MinGW Makefiles" ..
4) mingw32-make

I can see that the previous errors are appearing as warnings(snapshot attached), and example.exe has been created.

Even though the expected outcome is achieved with this change, I think suppressing errors to the warnings is not the way to solve this issue. I mean the build should be clean with no errors or warnings.

Kody’s earlier suggestion resolved the issue for me. But I’d still like to hear your recommendations on any further improvements.

Regards,
Akshay

I’ve raised this PR to switch the default tick size to 32 bits to avoid this warning for Windows builds. Users can still switch to 64 bit ticks.