fossapup64 9.5: devx X11 Library 'Incompatibilities' [SOLVED]

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
ozboomer
Posts: 92
Joined: Sun Dec 20, 2020 12:49 am
Location: Blackburn, Australia
Has thanked: 10 times
Been thanked: 9 times

fossapup64 9.5: devx X11 Library 'Incompatibilities' [SOLVED]

Post by ozboomer »

I'm making my way through building a Frugal installation save file using Fossapup64-9.5 and it's going well, although I do trip myself up sometimes...

One of these trip-ups involves building a simple program that links against X11 libraries.

I'm not flash with understanding how the 'gcc ecosystem' works... but let's just go with this...

To try and build the program, I am using the command line:

Code: Select all

root# gcc -Wall xrsel.c -o xrsel -lX11
root#

As shown, the executable is built Ok (now that I understand that the order of the flags, etc is important)... but when I run the program, the following error is thrown:

Code: Select all

root# xrsel
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
xrsel: error while loading shared libraries: libX11.so.6: wrong ELF class: ELFCLASS64
root#

From the bit of study I've done, this would indicate that there is some incompatibility between the libraries that the linker tries to use. The X11 libraries seem to include the following:

Code: Select all

root# find /usr/lib -iname "*libx11.so*"
/usr/lib/x86_64-linux-gnu/libX11.so.6
/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
/usr/lib/x86_64-linux-gnu/libX11.so
root# 

I have the normal 'devx' SFS loaded (devx_fossapup64_9.5.sfs), which I understand should give me all I need to build this sort of program...

I can build and run the program Ok on Slacko 6.3.2 (32 bit)... but that image won't run on fossapup64.

I ran 'find', looking for X11 directories on both platforms (see slacko.txt and fossa.txt) and did an ldconfig -p on both as well (see ldconfig-cache-BOTH.txt - it seems I can only attach 3 files) ... but I don't really know what I'm looking for in these outputs.

The C code I'm using follows:

Code: Select all

// -------------------------------------------------------------------------
//  xrsel - return geometry of a selected rectangular region on an X display
//  jjg, 3-Oct-2015
//
//  To build the program:
//     # gcc -Wall xrsel.c -o xrsel -lx11
//
//  References (including original code):
//    * https://bbs.archlinux.org/viewtopic.php?id=85378
//
// -------------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/cursorfont.h>

int main(void)
{
  int rx = 0, ry = 0, rw = 0, rh = 0;
  int rect_x = 0, rect_y = 0, rect_w = 0, rect_h = 0;
  int btn_pressed = 0, done = 0;

  XEvent ev;
  Display *disp = XOpenDisplay(NULL);

  if(!disp)
    return EXIT_FAILURE;

  Screen *scr = NULL;
  scr = ScreenOfDisplay(disp, DefaultScreen(disp));

  Window root = 0;
  root = RootWindow(disp, XScreenNumberOfScreen(scr));

  Cursor cursor, cursor2;
  cursor = XCreateFontCursor(disp, XC_left_ptr);
  cursor2 = XCreateFontCursor(disp, XC_lr_angle);

  XGCValues gcval;
  gcval.foreground = XWhitePixel(disp, 0);
  gcval.function = GXxor;
  gcval.background = XBlackPixel(disp, 0);
  gcval.plane_mask = gcval.background ^ gcval.foreground;
  gcval.subwindow_mode = IncludeInferiors;

  GC gc;
  gc = XCreateGC(disp, root,
                 GCFunction | GCForeground | GCBackground | GCSubwindowMode,
                 &gcval);

  /* this XGrab* stuff makes XPending true ? */
  if ((XGrabPointer
       (disp, root, False,
        ButtonMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
        GrabModeAsync, root, cursor, CurrentTime) != GrabSuccess))
    printf("couldn't grab pointer:");

  if ((XGrabKeyboard
       (disp, root, False, GrabModeAsync, GrabModeAsync,
        CurrentTime) != GrabSuccess))
    printf("couldn't grab keyboard:");

  while (!done) {
    while (!done && XPending(disp)) {
      XNextEvent(disp, &ev);
      switch (ev.type) {
        case MotionNotify:
        /* this case is purely for drawing rect on screen */
          if (btn_pressed) {
            if (rect_w) {
              /* re-draw the last rect to clear it */
              XDrawRectangle(disp, root, gc, rect_x, rect_y, rect_w, rect_h);
            } else {
              /* Change the cursor to show we're selecting a region */
              XChangeActivePointerGrab(disp,
                                       ButtonMotionMask | ButtonReleaseMask,
                                       cursor2, CurrentTime);
            }
            rect_x = rx;
            rect_y = ry;
            rect_w = ev.xmotion.x - rect_x;
            rect_h = ev.xmotion.y - rect_y;

            if (rect_w < 0) {
              rect_x += rect_w;
              rect_w = 0 - rect_w;
            }
            if (rect_h < 0) {
              rect_y += rect_h;
              rect_h = 0 - rect_h;
            }
            /* draw rectangle */
            XDrawRectangle(disp, root, gc, rect_x, rect_y, rect_w, rect_h);
            XFlush(disp);
          }
          break;
        case ButtonPress:
          btn_pressed = 1;
          rx = ev.xbutton.x;
          ry = ev.xbutton.y;
          break;
        case ButtonRelease:
          done = 1;
          break;
      }
    }
  }
  /* clear the drawn rectangle */
  if (rect_w) {
    XDrawRectangle(disp, root, gc, rect_x, rect_y, rect_w, rect_h);
    XFlush(disp);
  }
  rw = ev.xbutton.x - rx;
  rh = ev.xbutton.y - ry;
  /* cursor moves backwards */
  if (rw < 0) {
    rx += rw;
    rw = 0 - rw;
  }
  if (rh < 0) {
    ry += rh;
    rh = 0 - rh;
  }

  XCloseDisplay(disp);

// if ( (rw == 0) && (rh == 0) ) {
//    printf("0\n");
//    return(EXIT_FAILURE);
// }

  printf("%dx%d+%d+%d\n",rw,rh,rx,ry);

  return EXIT_SUCCESS;
}

// [eof]

Otherwise, I'm using fosspapup64 9.5 and slacko 6.3.2 with their respective devx SFS files.

I'd appreciate any thoughts on how to resolve this problem.

Attachments
ld-config-cache-BOTH.txt
(180.95 KiB) Downloaded 15 times
fossa.txt
(2.36 KiB) Downloaded 15 times
slacko.txt
(764 Bytes) Downloaded 16 times
Last edited by ozboomer on Tue Aug 22, 2023 9:31 pm, edited 1 time in total.

Daily Use Puppies: F96-CE (migrating), Xenial64 7.5, Slacko 6.3.2... Proud Puppy enthusiast since 2004
C, Perl, cmd/DCL/bash... for sysadmin, CLI tools... under DOS, Windoze, VMS, Linux... on PC, VAX... for 45+ years... :roll:

Burunduk
Posts: 251
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 7 times
Been thanked: 127 times

Re: fossapup64 9.5: devx X11 Library 'Incompatibilities'

Post by Burunduk »

I've just tried to compile it on my Fossapup64-9.5 and it works:

Code: Select all

root# gcc -Wall -o xrsel xrsel.c -lX11
root# ./xrsel 
991x465+136+105
root# 

Are you sure you are running the binary you've compiled and not something else? Your working directory is probably not in the PATH and the command that returns an error is xrsel. It should be ./xrsel. Some other xrsel is in the PATH and maybe it's a binary compiled on a 32-bit system. Just a guess.

User avatar
rockedge
Site Admin
Posts: 6540
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2748 times
Been thanked: 2620 times
Contact:

Re: fossapup64 9.5: devx X11 Library 'Incompatibilities'

Post by rockedge »

maybe it's a binary compiled on a 32-bit system. Just a guess.

It appears this is the case!

Code: Select all

root# xrsel
ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
xrsel: error while loading shared libraries: libX11.so.6: wrong ELF class: ELFCLASS64
ozboomer
Posts: 92
Joined: Sun Dec 20, 2020 12:49 am
Location: Blackburn, Australia
Has thanked: 10 times
Been thanked: 9 times

Re: fossapup64 9.5: devx X11 Library 'Incompatibilities'

Post by ozboomer »

Burunduk wrote: Tue Aug 22, 2023 11:31 am

Are you sure you are running the binary you've compiled and not something else? Your working directory is probably not in the PATH and the command that returns an error is xrsel. It should be ./xrsel. Some other xrsel is in the PATH and maybe it's a binary compiled on a 32-bit system. Just a guess.

Yup.. that was it. Running the wrong image.

Dang. Wot a weak, rookie error on my part... :cry: I'm obviously losing it in my old age... :D

Fanx! a heap.

Daily Use Puppies: F96-CE (migrating), Xenial64 7.5, Slacko 6.3.2... Proud Puppy enthusiast since 2004
C, Perl, cmd/DCL/bash... for sysadmin, CLI tools... under DOS, Windoze, VMS, Linux... on PC, VAX... for 45+ years... :roll:

Post Reply

Return to “Users”