nco build error: undefined reference to `nco_yyerror' and `nco_yyparse'

Help
2014-01-27
2017-04-20
  • raglan_road

    raglan_road - 2014-01-27

    Hi all,

    I'm trying to build nco-4.4.0 on a 64-bit linux machine with Intel compilers, following the configure/make/make install route. During the 'make' phase, I end up with the following errors:

    ncap_utl.o: In function `ncap_var_write':
    ncap_utl.c:(.text+0x390): undefined reference to `nco_yyerror'
    ncap.o: In function `main':
    ncap.c:(.text+0x1a13): undefined reference to `nco_yyparse'
    ncap_yacc.o: In function `yyparse':
    ncap_yacc.c:(.text+0x1a94): undefined reference to `nco_yyerror'
    ncap_yacc.c:(.text+0x1ba0): undefined reference to `nco_yyerror'
    ncap_yacc.c:(.text+0x21c2): undefined reference to `yylex'
    ncap_yacc.c:(.text+0x22f3): undefined reference to `yylex'
    ncap_lex.o: In function `nco_yylex':
    ncap_lex.c:(.text+0x135d): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x187b): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x2284): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x234b): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x23ef): undefined reference to `nco_yyerror'
    ncap_lex.o:ncap_lex.c:(.text+0x24a1): more undefined references to `nco_yyerror' follow
    make[3]: *** [ncap] Error 1
    

    Google didn't yield a solution. Can someone tell me why I'm getting these errors?

    Thanks,
    Sourish

     
  • Charlie Zender

    Charlie Zender - 2014-01-27

    It means the C code is not finding/linking to the parser/lexer code objects
    that should have been compiled by bison and flex. Please verify bison/flex are installed correctly. Please include their portion of the build output in any further correspondence.
    cz

     
  • raglan_road

    raglan_road - 2014-01-28

    Thanks for responding. My system is an Ubuntu system, and I have the following packages installed

    flex
    bison
    libbison-dev
    

    The strange thing is that -- as far as bison and flex are concerned -- I have the same packages on a different Ubuntu system, and I could build NCO on that one just fine.

    When I './configure' on the problem system, the summary at the end is

    Configuration Parameters:
    AR_FLAGS............. cru
    CC................... icc -std=gnu99
    CFLAGS............... -O3 -xHost -fPIC -m64 -fp-model strict -std=c99 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE
    CPP.................. icc -E
    CPPFLAGS............. -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include  -I/usr/include -I/usr/local/include -D_BSD_SOURCE -D_POSIX_SOURCE -no-gcc
    CXX.................. icpc
    CXXFLAGS.............  -cxxlib-gcc
    OPENMP_CFLAGS.........-fopenmp
    ENABLE_DAP_NETCDF.... no
    ENABLE_DAP........... no
    ENABLE_GSL........... yes
    HAVE_NETCDF4_H....... yes
    ENABLE_NETCDF4....... yes
    NETCDF4_ROOT......... /usr/local
    ENABLE_UDUNITS....... no
    ENABLE_UDUNITS2...... yes
    GSL_ROOT............. /usr
    HAVE_ANTLR........... runantlr
    HOST................. 
    host................. x86_64-unknown-linux-gnu
    HOSTNAME............. basulinux
    LDFLAGS.............. -L/usr/local/lib -lnetcdf -L/usr/local/lib -L/usr/local/lib  -L/usr/local/lib
    LIBS................. -ludunits2 -lexpat -lgsl -lm -lnetcdf -lnetcdf  -L/usr/lib -lgsl -lgslcblas -lm -ludunits2
    install prefix ...... /usr/local
    

    I do get a strange WARNING halfway through the configure process:

    configure: WARNING: cstdlib: present but cannot be compiled
    configure: WARNING: cstdlib:     check for missing prerequisite headers?
    configure: WARNING: cstdlib: see the Autoconf documentation
    configure: WARNING: cstdlib:     section "Present But Cannot Be Compiled"
    configure: WARNING: cstdlib: proceeding with the compiler's result
    configure: WARNING:     ## --------------------------------------------- ##
    configure: WARNING:     ## Report this to nco-bugs@lists.sourceforge.net ##
    configure: WARNING:     ## --------------------------------------------- ##
    

    During 'make', the error at which I get stuck is

    Making all in nco
    make[3]: Entering directory `/home/ccg/basu/Downloads/packages/nco-4.4.0/src/nco'
    /bin/bash ../../libtool --tag=CXX  --tag=CC   --mode=link icc -std=gnu99  -O3 -xHost -fPIC -m64 -fp-model strict -std=c99 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE  -L/usr/local/lib -lnetcdf -L/usr/local/lib -L/usr/local/lib  -L/usr/local/lib -o ncap ncap_utl.o ncap.o ncap_yacc.o ncap_lex.o libnco.la -ludunits2 -lexpat -lgsl -lm -lnetcdf -lnetcdf  -L/usr/lib -lgsl -lgslcblas -lm -ludunits2
    libtool: link: icc -std=gnu99 -O3 -xHost -fPIC -m64 -fp-model strict -std=c99 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE -o ncap ncap_utl.o ncap.o ncap_yacc.o ncap_lex.o  -L/usr/local/lib ./.libs/libnco.a /usr/local/lib/libnetcdf.so /usr/local/lib/libhdf5_hl.so /usr/local/lib/libhdf5.so -ldl -lz -L/usr/lib -lgsl -lgslcblas -lm /usr/local/lib/libudunits2.so -lexpat
    icc: command line warning #10121: overriding '-std=gnu99' with '-std=c99'
    ncap_utl.o: In function `ncap_var_write':
    ncap_utl.c:(.text+0x390): undefined reference to `nco_yyerror'
    ncap.o: In function `main':
    ncap.c:(.text+0x1a13): undefined reference to `nco_yyparse'
    ncap_yacc.o: In function `yyparse':
    ncap_yacc.c:(.text+0x1a94): undefined reference to `nco_yyerror'
    ncap_yacc.c:(.text+0x1ba0): undefined reference to `nco_yyerror'
    ncap_yacc.c:(.text+0x21c2): undefined reference to `yylex'
    ncap_yacc.c:(.text+0x22f3): undefined reference to `yylex'
    ncap_lex.o: In function `nco_yylex':
    ncap_lex.c:(.text+0x135d): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x187b): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x2284): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x234b): undefined reference to `nco_yyerror'
    ncap_lex.c:(.text+0x23ef): undefined reference to `nco_yyerror'
    ncap_lex.o:ncap_lex.c:(.text+0x24a1): more undefined references to `nco_yyerror' follow
    make[3]: *** [ncap] Error 1
    

    Does this help?

    Sourish

     
  • Charlie Zender

    Charlie Zender - 2014-01-28

    i've never seen that WARNING before. the problem is almost certainly related toyour using icc not gcc. we will look into this on our system that has icc.
    stay tuned.
    cz

     
  • raglan_road

    raglan_road - 2014-01-28

    I don't know if this clears or confuses, but the other Ubuntu system I mentioned, the one on which I could build nco successfully, also uses icc.

     
  • Charlie Zender

    Charlie Zender - 2014-01-28

    it's a mystery. the functions it cannot find are defined in ncap_yacc.o, which appears to have compiled.... i suggest you erase nco, and try to rebuilt from scratch. the WARNING is probably related to ncap2 code which you havn't ever gotten to try to compile yet.

     
  • raglan_road

    raglan_road - 2014-01-28

    Your solution worked! I had done 'make clean' many times before, and that did not solve the issue, but removing the tree and re-untarring NCO did the trick (I still have no idea why).

    FYI, my 'configure' line is

    ./configure --prefix=/usr/local --enable-netcdf-4 --enable-udunits2 CC='icc' CFLAGS='-O3 -xHost -fPIC -m64 -fp-model strict' LDFLAGS='-L/usr/local/lib' CPPFLAGS='-I/usr/local/include' CXX='icpc' CXXFLAGS=$CFLAGS NETCDF_INC=/usr/local/include NETCDF_LIB=/usr/local/lib NETCDF4_ROOT=/usr/local UDUNITS2_PATH=/usr/local
    
     
  • Charlie Zender

    Charlie Zender - 2014-01-28

    you owe me beer :)

     
  • raglan_road

    raglan_road - 2017-04-11

    Hi Charlie,

    I'm back, after more than three years :-) This time I'm trying to build nco-4.6.5 on a new computer system, which ends with a

    undefined reference to `yy_scan_string'
    

    error. Google searches for that error led me back to my own issue reported in 2014. This time, unfortunately, re-untarring nco did not solve the problem :-(

    I configured nco with:

    ./configure --prefix=/discover/nobackup/projects/tm5var4d/packages/nco/4.6.5 --enable-netcdf-4 --enable-openmp --enable-dap --enable-udunits2 CC=icc CFLAGS='-O3 -g -fPIC -fp-model strict -m64' CXX=icpc CXXFLAGS=$CFLAGS NETCDF_ROOT=/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1 UDUNITS2_PATH=/discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24
    

    which produced the summary

    Configuration Parameters:
    AR_FLAGS............. cru
    CC................... icc -std=gnu99
    CFLAGS............... -O3 -g -fPIC -fp-model strict -m64 -fopenmp -std=c99 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE
    CPP.................. icc -E
    CPPFLAGS............. -I/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/include -I/discover/nobackup/projects/tm5var4d/packages/hdf5/1.10.0-patch1/include -I/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/include  -I/discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24/include -D_BSD_SOURCE -D_POSIX_SOURCE
    CXX.................. icpc
    CXXFLAGS.............  -cxxlib-gcc
    ENABLE_DAP........... yes
    ENABLE_ESMF...........no
    ENABLE_GSL........... no
    ENABLE_NETCDF4....... yes
    ENABLE_OPENMP........ yes
    ENABLE_UDUNITS....... no
    ENABLE_UDUNITS2...... yes
    GSL_ROOT............. 
    HAVE_ANTLR........... no
    HAVE_MAKEINFO........ yes
    HAVE_NETCDF4_H....... yes
    HOST................. discover07
    HOSTNAME............. discover07
    LDFLAGS.............. -L/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib -lnetcdf -L/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib  -L/discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24/lib
    LIBS................. -ludunits2 -lexpat -lm -lnetcdf -lnetcdf -lnetcdf  -lcurl -ludunits2
    NETCDF_ROOT.......... /discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1
    OPENMP_CFLAGS........ -fopenmp
    host................. x86_64-unknown-linux-gnu
    install prefix ...... /discover/nobackup/projects/tm5var4d/packages/nco/4.6.5
    

    At the 'make' stage, I get the error:

    ncap_lex.l(970): warning #266: function "yy_scan_string" declared implicitly
          yy_scan_string(spt_arg_cat);
          ^
    
    ncap_lex.l(1094): warning #266: function "yy_scan_string" declared implicitly
        yy_scan_string(fnl_sng);
        ^
    
    mv -f .deps/ncap_lex.Tpo .deps/ncap_lex.Po
    /bin/sh ../../libtool --tag=CXX  --tag=CC   --mode=link icc -std=gnu99  -O3 -g -fPIC -fp-model strict -m64 -fopenmp -std=c99 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE  -L/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib -lnetcdf -L/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib  -L/discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24/lib -o ncap ncap_utl.o ncap.o ncap_yacc.o ncap_lex.o libnco.la -ludunits2 -lexpat -lm -lnetcdf -lnetcdf -lnetcdf  -lcurl -ludunits2
    libtool: link: icc -std=gnu99 -O3 -g -fPIC -fp-model strict -m64 -fopenmp -std=c99 -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE -o .libs/ncap ncap_utl.o ncap.o ncap_yacc.o ncap_lex.o  -L/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib -L/discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24/lib ./.libs/libnco.so -lexpat -lm /discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib/libnetcdf.so -lcurl /discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24/lib/libudunits2.so -fopenmp -Wl,-rpath,/discover/nobackup/projects/tm5var4d/packages/nco/4.6.5/lib -Wl,-rpath,/discover/nobackup/projects/tm5var4d/packages/netcdf-c/4.4.1.1/lib -Wl,-rpath,/discover/nobackup/projects/tm5var4d/packages/udunits/2.2.24/lib
    ncap_lex.o: In function `ncap_ntl_scn':
    /gpfsm/dnb32/sbasu1/build/nco-4.6.5/src/nco/ncap_lex.l:970: undefined reference to `yy_scan_string'
    ncap_lex.o: In function `ncap_ncwa_scn':
    /gpfsm/dnb32/sbasu1/build/nco-4.6.5/src/nco/ncap_lex.l:1094: undefined reference to `yy_scan_string'
    make[4]: *** [ncap] Error 1
    make[4]: Leaving directory `/gpfsm/dnb32/sbasu1/build/nco-4.6.5/src/nco'
    make[3]: *** [all] Error 2
    make[3]: Leaving directory `/gpfsm/dnb32/sbasu1/build/nco-4.6.5/src/nco'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/gpfsm/dnb32/sbasu1/build/nco-4.6.5/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/gpfsm/dnb32/sbasu1/build/nco-4.6.5'
    make: *** [all] Error 2
    

    Any idea what could be going wrong? Or why cleaning up the nco build directory is not helping this time?

     
    • Charlie Zender

      Charlie Zender - 2017-04-12

      you must be sure that the bison and flex packages are installed (not yacc and lex). those build nco_yy_scan_string(), but your build looks instead for yy_scan_string(). not sure why. if successful your executables should behave thusly:

      zender@edison06:~> nm `which ncwa` | grep scan_string
      000000000040e290 T nco_yy_scan_string
      
       
  • raglan_road

    raglan_road - 2017-04-13

    My system seems to have bison and flex installed:

    sbasu1@discover17 nco-4.6.5 $ ls -l `which bison`
    -rwxr-xr-x 1 root root 258672 2009 Feb 20 21:51:31 /usr/bin/bison
    sbasu1@discover17 nco-4.6.5 $ ls -l `which flex`
    -rwxr-xr-x 1 aknister k3000 317792 2017 Mar 07 18:15:57 /usr/local/other/SLES11.3/pkgsrc/2016Q4/bin/flex
    
     
  • raglan_road

    raglan_road - 2017-04-20

    I asked the developer of the OpenSuSE binary, he said he never had bison/flex problems.
    Also, I'm trying to build on SLES, not OpenSuSE, so maybe an OpenSuSE fix wouldn't have worked anyway.

    Is there some part of nco that I can disable to get rid of this error? I primarily use ncra, ncks, ncwa and ncrcat. Is there a way to build those and forget about the part that won't compile?

     
  • Charlie Zender

    Charlie Zender - 2017-04-20

    Here is ncap_lex.c. diff it with the one produced on your system. replace "yy_scan_string" in yours with "nco_yy_scan_string". then "make" again. also, i notice your bison is from 2009, eight years ago. this might be a problem.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks