How to fix “cgo-builtin-prolog:1: stddef.h: No such file or directory” in the golang program on Windows 10
So here’s some back story: Last Sunday, I was trying to write a Go program by following a YouTube tutorial. The simple program is a basic CRM API that uses Go-Fiber and GORM. The database platform I was using is SQLite. After following the tutorial for some time this part of the video is when the Lecturer is compiling the program. But, strangely it shows an error on mine.
So a couple of head scratching later, I started to do some research on Google. Many had the same problem but, mostly they’re using either Linux or Mac. But from there I was able to find, that the issue lies in the GCC (GNU Compiler Collection) that’s outdated. See in the picture above that executing.
gcc -v
It shows that the GCC version on my computer is version 2.95 which isn’t enough. So I downloaded a newer version online and it was called TDM-GCC installer (shout out to the creator they rocks). So here step-by-step on how I solve the issue:
#1. Download the GCC installer file from the website. Navigate by clicking the link below.
#2. Run the installer. And Click “Create”
#3. Choose the “MinGW -w64/TDM64 (32-bit and 64-bit)”
#4. Type the path of where you want to put the Instalation file. (Leave it at default)
#5. Then, after the installation is done. You need to search for “View advanced system settings”
#6. Press the System Variables Button
#7. Search for the system variable named “PATH” and press “edit”
#8. Move the “C:\TDM-GCC-64\bin” to the very top. Then press ok twice and restart the computer
#9. Lastly, verify that the GCC is version 10 by opening your terminal and executing
gcc -v
Note: The GCC version in this tutorial might be different from what you install on your computer depending on which TPM GCC installer you download. This tutorial using TDM-GCC version 10 64-bit
This is a fun experience working with the Go programming language. Because I didn’t have much experience with Go, to begin with so a lot of head-scratching was involved. But, in the end, it worked out. I hope this might help someone who has the same problem thank you.