Game Development Community

TorqueDemo.bin: undefined symbol: X11_KeyToUnicode

by Philippe C · in Torque Game Engine · 10/13/2006 (10:12 pm) · 10 replies

I just install the new version of ubuntu "edgy eft" , 6.10.

When I launch torqueDemo I get the following message :

torqueDemo.bin: symbol lookup error: torqueDemo_DEBUG.bin: undefined symbol: X11_KeyToUnicode

When I recompile the torque code I get the following message during linking :

--> Linking out.GCC4.DEBUG/torqueDemo_DEBUG.bin
out.GCC4.DEBUG/platformX86UNIX/x86UNIXInputManager.obj: In function 'MapKey':
platformX86UNIX/x86UNIXInputManager.cc:64: undefined reference to 'X11_KeyToUnicode'
platformX86UNIX/x86UNIXInputManager.cc:68: undefined reference to 'X11_KeyToUnicode'
platformX86UNIX/x86UNIXInputManager.cc:72: undefined reference to 'X11_KeyToUnicode'
collect2: ld returned 1 exit status
make[1]: *** [out.GCC4.DEBUG/torqueDemo_DEBUG.bin] Error 1
make: *** [default] Error 2


This message is due to the libsdl , the function X11_KeyToUnicode is deprecated since a long time ago, and it is removed from the new version delivered with ubuntu.
I can patch my ubuntu version or used an older version of SDL
packages.debian.org/changelogs/pool/main/libs/libsdl1.2/libsdl1.2_1.2.11-3/chang...

But i wonder if it it is possible to change the torque code ( see in the post below the code ) ?

Is someone could help me ?

Philippe C

#1
10/13/2006 (10:13 pm)
This code is extracted from : ../platformX86UNIX/x86UNIXInputManager.cc

// defined in SDL
==>> extern "C" Uint16 X11_KeyToUnicode( SDLKey keysym, SDLMod modifiers );

//==============================================================================
// Static helper functions
//==============================================================================
static void MapKey(Uint16 SDLkey, U8 tkey, KeySym xkeysym)
{ 
   DisplayPtrManager xdisplay;
   Display* display = xdisplay.getDisplayPointer();

   SDLtoTKeyMap[SDLkey] = tkey; 

   Uint16 key = 0;
   SDLKey skey = (SDLKey)SDLkey;
   SDLMod mod = KMOD_NONE;
   // lower case
 ==>>   key = X11_KeyToUnicode( skey, mod );
   AsciiTable[tkey].lower.ascii = key;
   // upper case
   mod = KMOD_LSHIFT;
 ==>>   key = X11_KeyToUnicode( skey, mod );
   AsciiTable[tkey].upper.ascii = key;
   // goofy (i18n) case
   mod = KMOD_MODE;
 ==>>   key = X11_KeyToUnicode( skey, mod );
   AsciiTable[tkey].goofy.ascii = key;

#if 0
   if (xkeysym == 0)
      return;

   XKeyPressedEvent fooKey;
   const int keybufSize = 256;
   char keybuf[keybufSize];

   // find the x keycode for the keysym
   KeyCode xkeycode = XKeysymToKeycode(
      display, xkeysym);

//   Display *dpy = XOpenDisplay(NULL);
//    KeyCode xkeycode = XKeysymToKeycode(
//       dpy, xkeysym);

   if (!xkeycode)
      return;     

   // create an event with the keycode
   dMemset(&fooKey, 0, sizeof(fooKey));
   fooKey.type = KeyPress;
   fooKey.display = display;
   fooKey.window = DefaultRootWindow(display);
   fooKey.time = CurrentTime;
   fooKey.keycode = xkeycode;

   // translate the event with no modifiers (yields lowercase)
   KeySym dummyKeySym;
   int numChars = XLookupString(
      &fooKey, keybuf, keybufSize, &dummyKeySym, NULL);
   if (numChars)
   {
      //Con::printf("assigning lowercase string %c", *keybuf);
      // ignore everything but first char
      AsciiTable[tkey].lower.ascii = *keybuf;
      AsciiTable[tkey].goofy.ascii = *keybuf;
   }
         
   // translate the event with shift modifier (yields uppercase)
   fooKey.state |= ShiftMask;
   numChars = XLookupString(&fooKey, keybuf, keybufSize, &dummyKeySym, NULL);
   if (numChars)
   {
      //Con::printf("assigning uppercase string %c", *keybuf);
      // ignore everything but first char
      AsciiTable[tkey].upper.ascii = *keybuf;
   }
#endif
}
#2
10/15/2006 (1:42 am)
I have opened a bug on ubuntu edgy :

launchpad.net/distros/ubuntu/+source/libsdl1.2/+bug/66217

I try to fix it ... eeeeuuuhh .... it is too hard for me ...

This SDL function is deprecated :
shinh.skr.jp/gonzui_sdl/gonzui.cgi/markup/SDL-1.2.9/src/video/x11/SDL_x11events....

769: /*
  770:  * This function is semi-official; it is not officially exported and should
  771:  * not be considered part of the SDL API, but may be used by client code
  772:  * that *really* needs it (including legacy code).
  773:  * It is slow, though, and should be avoided if possible.
  774:  *
  775:  * Note that it isn't completely accurate either; in particular, multi-key
  776:  * sequences (dead accents, compose key sequences) will not work since the
  777:  * state has been irrevocably lost.
  778:  */
  779: Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
  780: {
....
#3
10/15/2006 (3:52 pm)
What do the SDL people recommend to use instead?

And, worst case, couldn't you just copy that function out of SDL and paste it into Torque?
#4
10/18/2006 (2:07 pm)
I have found a work around solution : but I lost the upper case

I have updated ../platformX86UNIX/x86UNIXInputManager.cc as below.

// defined in SDL
//extern "C" Uint16 X11_KeyToUnicode( SDLKey keysym, SDLMod modifiers );  <=== comment

//==============================================================================
// Static helper functions
//==============================================================================
static void MapKey(Uint16 SDLkey, U8 tkey, KeySym xkeysym)
{ 
   DisplayPtrManager xdisplay;
   Display* display = xdisplay.getDisplayPointer();

   SDLtoTKeyMap[SDLkey] = tkey; 

   Uint16 key = 0;
   SDLKey skey = (SDLKey)SDLkey;
   SDLMod mod = KMOD_NONE;
   // lower case
   //key = X11_KeyToUnicode( skey, mod );       <=== comment
	 key = skey;                              //<=== key = default key 
   AsciiTable[tkey].lower.ascii = key;
   // upper case
   mod = KMOD_LSHIFT;
   //key = X11_KeyToUnicode( skey, mod );        <=== comment
   AsciiTable[tkey].upper.ascii = key;
   // goofy (i18n) case
   mod = KMOD_MODE;
   //key = X11_KeyToUnicode( skey, mod );        <=== comment
   AsciiTable[tkey].goofy.ascii = key;
....
#5
11/15/2006 (1:19 pm)
@Philippe C

well, that works for now. unfortunately, libsdl.org is down at the moment so we can't find the "proper" function to call.
#6
11/15/2006 (2:08 pm)
Christopher "Pacula" Corkum posted a fix on the T2D forums that bears reposting here for people without access:
Quote:There's been a couple reports of TGB not building due to 'undefined symbol: X11_KeyToUnicode' errors during the link process. While I have no doubt that I'm not the first to figure out this problem, I thought I'd post what I found about the issue and a simple fix for it.

From what I've gathered, X11_KeyToUnicode is an internal utility function in SDL that was apparently not meant to be externally usable, and never part of the SDL spec. For some reason however (bug? feature?) it was made public, and used by a number of programs. Recent versions of SDL have this bug fixed, and the function hidden, to the detriment of any program that had used it.

Fortunately, fixing this problem is almost trivial - X11_KeyToUnicode is only used in one place in TGB, and an earlier version of the code that doesn't use this function was left in the source code, merely disabled. Dig down to engine/source/platformX86UNIX in the source tree, and open up x86UNIXInputManager.cc. Scroll down a bit, and you'll see a MapKey() function. Comment out the currently active code there, and remove the #if 0/#endif pair disabling the old version of the code below it, and the X11_KeyToUnicode errors should no longer be an issue.

Gary (-;
#7
11/15/2006 (2:16 pm)
@ Gary

yes it works

thanks

Philippe
#8
11/15/2006 (2:50 pm)
You can found a libsdl.so.0 on the tgb package just copy to the same folder where you have the tgb binari
#9
11/30/2006 (12:00 am)
You know, why did the libDSL developers hide that symbol knowing that people were using it? Why not just output a message to stderr indicating that it shouldn't be used rather than just up and chaning it w/o warning ><
#10
12/24/2006 (3:10 pm)
For your information a fix is provided with the next version of ubuntu : Feisty ( APRIL 2007 )

launchpad.net/distros/ubuntu/+source/libsdl1.2/+bug/66217