fossapup64 9.5: devx X11 Library 'Incompatibilities' [SOLVED]
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.