Compile ncdf4.dll with Visual Studio. In 64 bits using the example code in the help page for ncdim_def, works if compiled with VS, however if using gcc, crash at nc_create. Note that same works with 32 bits R and netcdf4. Curious.