'Compiling C code with gcc without a makefile on Mac M1

I am new to MacOS, I've always written code on Linux. I was used to compiling C files with gcc, simply like

gcc -o file file.c -lm -lgsl

where here I assumed the code to contain among its includes

#include <math.h>
#include <gsl/gsl_rng.h>

Of course the library gsl is correctly installed on my Mac via homebrew, and so are pkg-config and "Command line tools", but still when I try to compile file.c I get an error message,

fatal error: 'gsl/gsl_rng.h' file not found
#include <gsl/gsl_rng.h>
         ^~~~~~~~~~~~~~~

The problem is not specific to gsl (I tried for instance with the library fftw3 and got the same result).

I've seen tons of people with the same kind of problems on new M1 Macs; I've read that gcc on Mac is really "clang", and different rules apply. A ton of mocking answers were suggesting to add the correct library paths to the makefile or the like. But actually I've never before felt the need for a makefile on Linux, and surely I don't want to start adding cflags and paths whenever I compile a code (I'm working on several machines with different operating systems, with my code stored on Cloud servers, so I assume I should write a makefile for each of them? Really?).

Has anyone found a proper fix?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source