I’m guessing you got this error after a pip install natcap.invest ?
If you still do have compilation errors, you could try using conda to first install some of the invest dependencies. Conda provides compiled binaries for libraries like gdal so you don’t have to compile them locally.
For example, conda install -c conda-forge "gdal>=3" numpy shapely rtree pip install natcap.invest