configure: error: Could not link to netcdf C library (SURFEX installation fail)

do flag

I want to install and run SURFEX on Ubuntu 18.04, so I'm following the steps explained here. when I run the make command in the src directory (compiling the master version of the code), after a while I get an error that says:

configure: error: Could not link to netcdf C library. Please set LDFLAGS; for static builds set LIBS to the results of nc-config --libs.

I tried this solution in the step before "make", i.e.

CFLAGS=$(nc-config --cflags) LDFLAGS=$(nc-config --libs) ./configure


CFLAGS=$(nc-config --cflags) LDFLAGS=$(nc-config --libs) . ../conf/profile_surfex-LXgfortran-SFX-V8-1-1-MPIAUTO-O2-X0

but I couldn't resolve the problem, probably because I don't know what I am doing. Could someone tell me how I set those flags?

hr flag
Is the netcdf development package installed on your system? Did the `nc-config` commands execute without error?
N0rbert avatar
zw flag
Have you followed ?
theWrongAlice avatar
do flag
@N0rbert, yes and that works, until I get this new error. I tried to solve it myself first and then I was busy for a while, so I'm picking it back up now
do flag

Apparently one package isn't listed on the site with instructions. You also need to install libcurl4-gnutls-dev. It works now.

au flag

I faced the same problem with Ubuntu 20.04 and this solution of theWrongAlice did the trick for me as well.

Installing libcurl4-gnutls-dev:

sudo apt-get install -y libcurl4-gnutls-dev

And before make:

CFLAGS=$(nc-config --cflags) LDFLAGS=$(nc-config --libs) ./configure

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.