@@ -517,14 +517,19 @@ void* get_xlib_handle()
517
517
// If we're not emulating a 32 bit mode (which is either native 32 bit
518
518
// or native 64 bit) - use the ordinary path for libX11
519
519
if (is_emulated_32bit () == FALSE) {
520
- const char default_x11_location [] = "/usr/lib/libX11.so.6" ;
521
520
// Usually, libX11 will reside in /usr/lib. On some 64-bit Linux
522
521
// distributions, it will reside in /usr/lib64.
523
- if (access (default_x11_location , F_OK ) == 0 ) {
524
- snprintf (library , MAX_LIBRARY_PATH , default_x11_location );
525
- } else {
526
- snprintf (library , MAX_LIBRARY_PATH , "/usr/lib64/libX11.so.6" );
522
+ const char default_x11_location [] = "/usr/lib/libX11.so.6" ;
523
+ const char debian_x11_location [] = "/usr/lib/x86_64-linux-gnu/libX11.so.6" ;
524
+ const char opensuse_x11_location [] = "/usr/lib64/libX11.so.6" ;
525
+ const char * possible_locations [] = {
526
+ default_x11_location , debian_x11_location , opensuse_x11_location };
527
+ int locations_len = sizeof (possible_locations ) / sizeof (char * );
528
+ int i = 0 ;
529
+ while (i < (locations_len - 1 ) && access (possible_locations [i ], F_OK ) != 0 ) {
530
+ i ++ ;
527
531
}
532
+ snprintf (library , MAX_LIBRARY_PATH , possible_locations [i ]);
528
533
} else {
529
534
// Use a path that usually contains the 32 bit libs in a 64 bit system.
530
535
snprintf (library , MAX_LIBRARY_PATH , "/usr/lib32/libX11.so.6" );
0 commit comments