Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake and Autotools builds broken when V2 API is disabled #736

Closed
edhartnett opened this issue Dec 22, 2017 · 1 comment
Closed

CMake and Autotools builds broken when V2 API is disabled #736

edhartnett opened this issue Dec 22, 2017 · 1 comment

Comments

@edhartnett
Copy link
Contributor

Thanks @gsjaardema for bringing this to light. Greg submitted a fix in a PR, but it introduces a new header file which is not needed. config.h should have all the information needed to determine if V2 is built.

Here's the error:

nc_test4/CMakeFiles/nc_test4_tst_vars2.dir/build.make:62: recipe for target 'nc_test4/CMakeFiles/nc_test4_tst_vars2.dir/tst_vars2.c.o' failed
make[2]: *** [nc_test4/CMakeFiles/nc_test4_tst_vars2.dir/tst_vars2.c.o] Error 1
CMakeFiles/Makefile2:4131: recipe for target 'nc_test4/CMakeFiles/nc_test4_tst_vars2.dir/all' failed
make[1]: *** [nc_test4/CMakeFiles/nc_test4_tst_vars2.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Build step 'Execute shell' marked build as failure
Finished: FAILURE

The autotools build fails like this:

tst_vars2.c: In function ‘main’:
tst_vars2.c:568:14: warning: implicit declaration of function ‘nccreate’; did you mean ‘nc_create’? [-Wimplicit-function-declaration]
       ncid = nccreate(FILE_NAME, NC_NETCDF4);
              ^~~~~~~~
              nc_create
tst_vars2.c:571:18: warning: implicit declaration of function ‘ncdimdef’; did you mean ‘nc_redef’? [-Wimplicit-function-declaration]
       dimid[0] = ncdimdef(ncid, LAT, LAT_LEN);
                  ^~~~~~~~
                  nc_redef
tst_vars2.c:571:33: error: ‘LAT’ undeclared (first use in this function)
       dimid[0] = ncdimdef(ncid, LAT, LAT_LEN);
                                 ^~~
tst_vars2.c:571:33: note: each undeclared identifier is reported only once for each function it appears in
tst_vars2.c:571:38: error: ‘LAT_LEN’ undeclared (first use in this function); did you mean ‘DIM1_LEN’?
       dimid[0] = ncdimdef(ncid, LAT, LAT_LEN);
                                      ^~~~~~~
                                      DIM1_LEN
tst_vars2.c:572:33: error: ‘LON’ undeclared (first use in this function)
       dimid[1] = ncdimdef(ncid, LON, LON_LEN);
                                 ^~~
tst_vars2.c:572:38: error: ‘LON_LEN’ undeclared (first use in this function); did you mean ‘LAT_LEN’?
       dimid[1] = ncdimdef(ncid, LON, LON_LEN);
                                      ^~~~~~~
                                      LAT_LEN
tst_vars2.c:575:15: warning: implicit declaration of function ‘ncvardef’; did you mean ‘nc_redef’? [-Wimplicit-function-declaration]
       varid = ncvardef(ncid, CXX_VAR_NAME, NC_FLOAT, VAR_DIMS2, dimid);
               ^~~~~~~~
               nc_redef
tst_vars2.c:578:7: warning: implicit declaration of function ‘ncclose’; did you mean ‘nc_close’? [-Wimplicit-function-declaration]
       ncclose(ncid);
       ^~~~~~~
       nc_close
tst_vars2.c:581:14: warning: implicit declaration of function ‘ncopen’; did you mean ‘nc_open’? [-Wimplicit-function-declaration]
       ncid = ncopen(FILE_NAME, 0);
              ^~~~~~
              nc_open
tst_vars2.c:582:7: warning: implicit declaration of function ‘ncinquire’; did you mean ‘nc_inq_var’? [-Wimplicit-function-declaration]
       ncinquire (ncid, &ndims, &nvars, &natts, &recdim);
       ^~~~~~~~~
       nc_inq_var

The config.h in both cases does include this:

/* do not build the netCDF version 2 API */
#define NO_NETCDF_2 1

The macro name is awkward, but it's a historical oddity, so we tolerate it, like the Roman-style robes we make graduates wear.

Greg also very thoughtfully submitted a fix (PR #656), but it unnecessarily introduces the netcdf_meta.h file, which is not needed and should not be used in tests.

I have fixed this on my current branch by using NO_NETCDF_2 where necessary in tst_vars2.c. I have also added some disable-v2 builds to my CI system to prevent it breaking again. ;-)

I will put my branch up for merge sometime next week.

@edhartnett
Copy link
Contributor Author

This is now fixed in master. Thanks @gsjaardema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant