undefined reference to "function name"

llewelly@edevnull.com llewelly@edevnull.com
Wed Sep 27 22:13:00 GMT 2000


Pavlos Parissis <surfking@x-treme.gr> writes:

> Hello all,
> Since i have installed RedHat 6.2 i have this problem.
> I am trying to compile a program i get errors about "undefined reference
> to"
> for instance :
> i tried to compile the following program
> #include <X11/extensions/XTest.h>
> #include <X11/keysym.h>
> 
> int main()
>     {
>     Display* disp = XOpenDisplay( NULL );
>     if( disp == NULL )
>         return 1;
>     XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock ),
> True, CurrentTime );
>     XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock ),
> False, CurrentTime );
>     XCloseDisplay( disp );
>     return 0;
>     }
> and i got
> gcc -o ./numclocks.e ./numclocks.o
> ./numclocks.o:
>  In function `main':
> ./numclocks.o(.text+0x9): undefined reference to `XOpenDisplay'
> ./numclocks.o(.text+0x30): undefined reference to `XKeysymToKeycode'
> ./numclocks.o(.text+0x42): undefined reference to `XTestFakeKeyEvent'
> ./numclocks.o(.text+0x57): undefined reference to `XKeysymToKeycode'
> ./numclocks.o(.text+0x69): undefined reference to `XTestFakeKeyEvent'
> ./numclocks.o(.text+0x75): undefined reference to `XCloseDisplay'
> collect2: ld returned 1 exit status

On my i686-linux-pc-gnu system, I successfully compiled and linked
  your example with the following command line:

gcc -g -v -Wall -L/usr/X11R6/lib -lX11 -lXtst X_fun.c

Note that if your X libs are not in /usr/X11R6/lib, you will need to
  change the -L options.

[snip]















More information about the Gcc-help mailing list