This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Hi Ed, > > Thanks for your suggestion. I tried the following > > *CFLAGS=-fPIC ./configure --prefix=/home/sandeep/NETCDF/netcdf-3.6.2 > --enable-shared && make check > * > But gave me a following errors (Error A) while installing... This is a problem with your C++ API. Are you going to use the C++ API? If not, I would just retry, with the --disable-cxx option to configure. > > Then tried the following options > > *C**FLAGS=-fPIC ./configure --prefix=/home/sandeep/NETCDF/netcdf-3.6.2 > -with-pic && make check* > > It gave me the following errors (Error B) while installing. These are NCO errors. NCO is a different package. First make sure you have netCDF working by running make check. If make check succeeds, then go on to NCO. The problem in error B is not from netCDF, so I can't tell you much. Sorry. :-( > > Please let me know if you find any clue or suspect anything which is > messing up the compilation. > Maybe your netCDF build already worked, if it completed OK. Run "make check" to be sure. Then try a "make distclean" on the NCO package, and start over again clean, and see if it works... Good luck! Ed > *ErrroA:* > > make check-TESTS > make[4]: Entering directory `/home/sandeep/NCO/nco-3.9.2/src/nco' > make[4]: Leaving directory `/home/sandeep/NCO/nco-3.9.2/src/nco' > make[3]: Leaving directory `/home/sandeep/NCO/nco-3.9.2/src/nco' > Making check in nco_c++ > make[3]: Entering directory `/home/sandeep/NCO/nco-3.9.2/src/nco_c++' > if /bin/sh ../../libtool --tag=CXX --tag=CXX --mode=compile g++ > -DHAVE_CONFIG_H -I. -I. -I../.. -DABORT_ON_ERROR -g -O2 -MT > libnco_c___la-nco_att.lo -MD -MP -MF ".deps/libnco_c___la-nco_att.Tpo" > -c -o libnco_c___la-nco_att.lo `test -f 'nco_att.cc' || echo > './'`nco_att.cc; \ > then mv -f ".deps/libnco_c___la-nco_att.Tpo" > ".deps/libnco_c___la-nco_att.Plo"; else rm -f > ".deps/libnco_c___la-nco_att.Tpo"; exit 1; fi > mkdir .libs > g++ -DHAVE_CONFIG_H -I. -I. -I../.. -DABORT_ON_ERROR -g -O2 -MT > libnco_c___la-nco_att.lo -MD -MP -MF .deps/libnco_c___la-nco_att.Tpo -c > nco_att.cc -fPIC -DPIC -o .libs/libnco_c___la-nco_att.o > In file included from nco_att.cc:9: > nco_att.hh:23:42: netcdf.h: No such file or directory > In file included from nco_att.hh:26, > from nco_att.cc:9: > nco_utl.hh:31:42: netcdf.h: No such file or directory > In file included from nco_att.hh:26, > from nco_att.cc:9: > nco_utl.hh:37: `NC_NOERR' was not declared in this scope > In file included from nco_utl.hh:58, > from nco_att.hh:26, > from nco_att.cc:9: > nco_dmn.hh:22:42: netcdf.h: No such file or directory > In file included from nco_utl.hh:58, > from nco_att.hh:26, > from nco_att.cc:9: > nco_dmn.hh:58: `NC_NOERR' was not declared in this scope > nco_dmn.hh:68: `NC_NOERR' was not declared in this scope > nco_dmn.hh:85: `NC_NOERR' was not declared in this scope > In file included from nco_utl.hh:59, > from nco_att.hh:26, > from nco_att.cc:9: > nco_var.hh:24:42: netcdf.h: No such file or directory > In file included from nco_utl.hh:59, > from nco_att.hh:26, > from nco_att.cc:9: > nco_var.hh:43: syntax error before `&' token > nco_var.hh:53: syntax error before `&' token > nco_var.hh:66: type specifier omitted for parameter `nc_type' > nco_var.hh:66: syntax error before `&' token > nco_var.hh:80: `NC_NOERR' was not declared in this scope > nco_var.hh:97: `NC_NOERR' was not declared in this scope > nco_var.hh:113: type specifier omitted for parameter `nc_type' > nco_var.hh:113: syntax error before `&' token > nco_var.hh:119: syntax error before `int' > nco_var.hh:125: syntax error before `int' > nco_var.hh:137: `NC_NOERR' was not declared in this scope > nco_var.hh:145: `NC_NOERR' was not declared in this scope > nco_var.hh:168: `NC_NOERR' was not declared in this scope > nco_var.hh:190: `NC_NOERR' was not declared in this scope > In file included from nco_att.hh:26, > from nco_att.cc:9: > nco_utl.hh:101: `NC_NOERR' was not declared in this scope > nco_utl.hh:106: syntax error before `&' token > nco_utl.hh:111: syntax error before `&' token > nco_utl.hh:116: syntax error before `&' token > nco_utl.hh:121: syntax error before `&' token > nco_utl.hh:132: syntax error before `float' > nco_utl.hh:137: syntax error before `double' > In file included from nco_att.cc:9: > nco_att.hh:44: syntax error before `&' token > nco_att.hh:53: syntax error before `&' token > nco_att.hh:63: syntax error before `&' token > nco_att.hh:72: syntax error before `&' token > nco_att.hh:82: syntax error before `&' token > nco_att.hh:90: syntax error before `&' token > nco_att.hh:100: syntax error before `&' token > nco_att.hh:108: syntax error before `&' token > nco_att.hh:118: syntax error before `&' token > nco_att.hh:126: syntax error before `&' token > nco_att.hh:151: syntax error before `&' token > nco_att.hh:162: type specifier omitted for parameter `nc_type' > nco_att.hh:162: syntax error before `&' token > nco_att.hh:176: `NC_NOERR' was not declared in this scope > nco_att.hh:185: `NC_NOERR' was not declared in this scope > nco_att.hh:211: `NC_NOERR' was not declared in this scope > nco_att.hh:236: type specifier omitted for parameter `nc_type' > nco_att.hh:236: syntax error before `&' token > nco_att.hh:242: syntax error before `int' > nco_att.hh:256: `NC_NOERR' was not declared in this scope > nco_att.cc:39: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:42: `nc_id' undeclared (first use this function) > nco_att.cc:42: (Each undeclared identifier is reported only once for each > function it appears in.) > nco_att.cc:42: `var_id' undeclared (first use this function) > nco_att.cc:42: `att_nm' undeclared (first use this function) > nco_att.cc:42: `att_typ' undeclared (first use this function) > nco_att.cc:42: `att_sz' undeclared (first use this function) > nco_att.cc:42: `att_val' undeclared (first use this function) > nco_att.cc:42: `nc_put_att_float' undeclared (first use this function) > nco_att.cc:43: `NC_NOERR' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:53: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:54: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc:54: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc: At global scope: > nco_att.cc:74: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:75: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:75: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:75: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc:77: `nc_put_att_double' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:88: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:89: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:89: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:89: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:89: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc: At global scope: > nco_att.cc:103: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:104: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:104: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:104: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:104: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:104: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc:106: `nc_put_att_int' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:116: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:117: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:117: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:117: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:117: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:117: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:117: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc: At global scope: > nco_att.cc:131: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:117: `int nco_put_att(...)' previously defined here > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:117: `int nco_put_att(...)' previously defined here > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:132: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc:134: `nc_put_att_short' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:144: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:132: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:132: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:117: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:145: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc: At global scope: > nco_att.cc:159: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:145: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:145: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:132: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:117: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:160: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc:162: `nc_put_att_long' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:172: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:160: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:160: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:145: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:132: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:117: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:173: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc: In function `int nco_put_att(const int&, const int&, const > std::string&, const std::string&)': > nco_att.cc:188: `nc_put_att_text' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:211: syntax error before `&' token > nco_att.cc: In function `int nco_put_att(...)': > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:173: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:173: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:160: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:145: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:132: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:117: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:104: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:89: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:75: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:54: `int nco_put_att(...)' previously defined here > nco_att.cc:212: redefinition of `int nco_put_att(...)' > nco_att.cc:40: `int nco_put_att(...)' previously defined here > nco_att.cc: At global scope: > nco_att.cc:228: type specifier omitted for parameter `nc_type' > nco_att.cc:228: syntax error before `&' token > nco_att.cc: In function `int nco_inq_att(...)': > nco_att.cc:234: `nc_inq_att' undeclared (first use this function) > nco_att.cc:235: `rcd_opt' undeclared (first use this function) > nco_att.cc: In function `int nco_inq_attid(const int&, const int&, const > std::string&, int&, const int&)': > nco_att.cc:252: `nc_inq_attid' undeclared (first use this function) > nco_att.cc: In function `int nco_inq_attname(const int&, const int&, const > int&, std::string&, const int&)': > nco_att.cc:312: `NC_MAX_NAME' undeclared (first use this function) > nco_att.cc:313: `att_nm_chr' undeclared (first use this function) > nco_att.cc:313: `nc_inq_attname' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:353: type specifier omitted for parameter `nc_type' > nco_att.cc:353: syntax error before `&' token > nco_att.cc: In function `int nco_inq_atttype(...)': > nco_att.cc:358: `nc_inq_atttype' undeclared (first use this function) > nco_att.cc: At global scope: > nco_att.cc:365: syntax error before `int' > nco_att.cc:371: `var_nm' was not declared in this scope > nco_att.cc:372: syntax error before `+=' token > nco_att.cc: In function `int nco_inq_attlen(const int&, const int&, const > std::string&, size_t&, const int&)': > nco_att.cc:390: `nc_inq_attlen' undeclared (first use this function) > nco_att.cc: In function `int nco_get_att(const int&, const int&, const > std::string&, std::string&)': > nco_att.cc:449: `nc_get_att_text' undeclared (first use this function) > nco_att.cc: In function `int nco_get_att(const int&, const int&, const > std::string&, float*&)': > nco_att.cc:471: `nc_get_att_float' undeclared (first use this function) > nco_att.cc: In function `int nco_get_att(const int&, const int&, const > std::string&, double*&)': > nco_att.cc:487: `nc_get_att_double' undeclared (first use this function) > make[3]: *** [libnco_c___la-nco_att.lo] Error 1 > make[3]: Leaving directory `/home/sandeep/NCO/nco-3.9.2/src/nco_c++' > make[2]: *** [check-recursive] Error 1 > make[2]: Leaving directory `/home/sandeep/NCO/nco-3.9.2/src' > make[1]: *** [check-recursive] Error 1 > make[1]: Leaving directory `/home/sandeep/NCO/nco-3.9.2' > make: *** [test] Error 2 > > > *Error B* > > gcc -std=gnu99 -g -O2 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE -o > .libs/ncap ncap_utl.o ncap.o ncap_yacc.o ncap_lex.o > -L/home/sandeep/NETCDF/netcdf-3.6.2/lib ./.libs/libnco.so -lnsl -lm > /home/sandeep/NETCDF/netcdf-3.6.2/lib/libnetcdf.a -Wl,--rpath > -Wl,/home/sandeep/NCO/nco-3.9.2/lib > ./.libs/libnco.so: undefined reference to `for_len_trim' > ./.libs/libnco.so: undefined reference to `for_trim' > ./.libs/libnco.so: undefined reference to `for_contig_array' > ./.libs/libnco.so: undefined reference to `for_cpystr' > collect2: ld returned 1 exit status > make[3]: *** [ncap] Error 1 > make[3]: Leaving directory `/home/sandeep/NCO/nco-3.9.2/src/nco' > > > > Unidata netCDF Support wrote: > >> Hi Russ, > >> > >> Thanks for the response. I need one help from you i.e. how to compile > >> NETCDF-3.6.2 version > >> with -fPIC option or how to validate that the libraries obtained from > >> certain compilation has been > >> compiled with -fPIC options. > >> > >> Once i can confirm myself about this, i might fix the problem with the > >> other software which is > >> using NETCDF libraries. > >> > >> regards > >> sandeep > >> > >> > > > > Howdy Sandeep! > > > > Set the CFLAGS env variable before running configure. > > > > Make sure you do a "make distclean" first. Like this in the borne shell: > > > > make distclean; CFLAGS=-fPIC ./configure --enable-shared && make check > > > > Also, you probably want to use the --disable-f77 --disable-cxx options to turn off the building of the Fortran 77, Fortran 90, and C++ APIs. They are not used by NCO. Otherwise you may have to set FFLAGS, F90FLAGS, and CXXFLAGS as well. > > > > Good luck! > > > > Ed > > > > Ticket Details > > =================== > > Ticket ID: KCB-778033 > > Department: Support netCDF > > Priority: Normal > > Status: Closed > > > > > > > -- > Dr. Sandeep Pattnaik > Research Associate > Department of Meteorology > Florida State University > Tallahassee,Fl,32306-4502 > Ph: 850-644-2232(W) > 850-575-9238(R) > Fax:850-644-9642 > > > Ticket Details =================== Ticket ID: KCB-778033 Department: Support netCDF Priority: Normal Status: Closed