0

I am not a C guru. I am trying to compile someone else's C code, and am getting the following error:

Undefined symbols for architecture x86_64:
   "_stdscr", referenced from:
      _new_line in libsms.a(cstatus.o)
      _message in libsms.a(cstatus.o)

the "stdscr" method comes from, I think, both "ncurses.h" and "curses.h". The code seems to be expecting "ncurses.h".

The "ncurses.h" file appears to define "stdscr" (no underscore in the name) whereas the linker is complaining about the symbol "_stdscr" (note the underscore).

I have -lncurses in my compiler flags, and I think that bit is working.

If I change the C source code to refer to the variable as "_stdscr", I get

error: ‘_stdscr’ undeclared

instead.

Can someone please

  1. explain where this underscore is coming from and what it's doing?
  2. help me how to know for sure that the ncurses.h header is being correctly found and referenced?
  3. point me in the right direction for further investigation?
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Tennessee Leeuwenburg
  • 1,693
  • 1
  • 12
  • 9
  • "I have -lncurses in my compiler flags, and I think that bit is working." What evidence do you have for that belief? – rici Apr 29 '17 at 22:59
  • What is libsms? Text messages or synthesis of musical sound? – aghast Apr 29 '17 at 23:01
  • Some compilers add an underscore automatically to external symbol names. You should treat it as if it said `stdscr`. Then you need to know where `stdscr` is defined; it should be defined by the `ncurses` library (and declared by the `ncurses.h` header). You need to link with the `ncurses` library — add `-lncurses` to the linking command line. – Jonathan Leffler Apr 29 '17 at 23:17
  • http://stackoverflow.com/q/2627511/12711 – Michael Burr Apr 29 '17 at 23:34
  • @rici well, a lack of errormessages, mainly. Is there a way to force the linker to provide a specific error message for the condition where I have specified a library (with -lncurses) but it isn't found? – Tennessee Leeuwenburg Apr 30 '17 at 02:54
  • Here is the what's getting executed: Making all in cdp /bin/sh ../libtool --tag=CC --mode=link gcc -O2 -DMACOSX -I/Users/tjl/Development/envs/me/include/X11/ -D_GNU_SOURCE -Dlinux -Dlinux64 -DLITTLE_ENDIAN -DFOPEN64 -DUSE_XOPEN_EXTENDED -DUNIX -Dunix -DTODAY="\"`date`\"" -L../common -lsms sms_clnt.o -L../ioi -L../ls -lioi -lls -lm -lncurses -o child child.o -ldl -lncurses -lm – Tennessee Leeuwenburg Apr 30 '17 at 02:56
  • libtool: link: gcc -O2 -DMACOSX -I/Users/tjl/Development/envs/me/include/X11/ -D_GNU_SOURCE -Dlinux -Dlinux64 -DLITTLE_ENDIAN -DFOPEN64 -DUSE_XOPEN_EXTENDED -DUNIX -Dunix "-DTODAY=\"Sun 30 Apr 2017 08:59:02 AEST\"" sms_clnt.o -o child child.o -L/Users/tjl/Development/ACCESS/sms/sms_src/common -lsms -L/Users/tjl/Development/ACCESS/sms/sms_src/ioi -L/Users/tjl/Development/ACCESS/sms/sms_src/ls -lioi -lls -ldl -lncurses -lm – Tennessee Leeuwenburg Apr 30 '17 at 02:57
  • @AustinHastings it's a legacy bit of kit, the homepage isn't even up any more, but here's a wikipedia page: https://en.wikipedia.org/wiki/Supervisor_Monitoring_Scheduler – Tennessee Leeuwenburg Apr 30 '17 at 02:58
  • If the library isn't found, an error message will be produced (provided that linking is required). – rici Apr 30 '17 at 03:02

0 Answers0