[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linker barfs



 
> Dear Sage members
 
>  I am attempting to compile a c program which calls the getch() 
> function  which is defined in the /usr/include/curses.h file  as
 
>  extern int  wgetch(WINDOW *)
 
>  When I attempt to make the executable the linker barfs with the
> following error message:
 
> Undefined            first referenced
> symbol                  in file
> wgetch                myprog.o
> stdscr                myprog.o
 
>  ld: fatal: Symbol referencing errors. No output written 
> *** Error code 1

>   But the function "wgetch"  is no where to be found in the header 
> files in /usr/include !!!
 
>  What did I do wrong ?????

	This is not a programming help list.  Programming
	curses programs is only marginally related to systems
	administration. (comp.unix.question or comp.lang.c 
	might be better venues).

	That said it sounds like you aren't real clear on your
	question.  

	First you say that wgetch() is defined in
	your curses.h file under /usr/include, then you say that
	it's "no where to be found." 

	Do you mean that wgetch() is SUPPOSED to be found in
	/usr/include/curses.h?  Do you have a /usr/include/curses.h?
	Are you using curses or ncurses?  What doesn't your actual
	#include directive look like?  What sort of command are you
	attempting to use to perform the compilation?  If you're
	using a make file --- include it (or a relevant portion of
	it).

	Also you say that the linker barfs.  That implies that 
	the compiler *doesn't*.  Also the fact that the .o files
	are being generated suggests that this is the case.  So,
	that suggests that the compiler *is* finding a function
	prototype for wgetch(), and is compiling that into a 
	set of library symbols which it is putting into the .o
	files.  The linker isn't finding the code associated with
	those symbols (normally "archived" into "libraries" ---
	using the 'ar' command to generate show .a files, and also
	commonly found in our "shared object" files or .so files
	on modern versions of Unix).

	That would suggest that you have to add the -lcurses or
	-lncurses directives to your ld command.

	In any event this seems off-topic for this list.  I'd 
	suggest taking it to a programming support mailing list
	or newsgroup --- preferably one that is dedicated to
	your platform.

	When asking questions of this sort in any public forum
	it's best to include the version and architecture of your
	OS, the compiler, and the shortest sample of code that
	you can cull out of your project that exhibits the problem.
	
> joe kane
> kanejm@netheaven.com

--
Jim Dennis  (800) 938-4078		consulting@starshine.org
Proprietor, Starshine Technical Services:  http://www.starshine.org