diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c
index 4b15f856b28ab5a2cf802071ffc1e38ffa4ce6a5..fa86b78524b853c90478a93aa95fb8f6a3f41eff 100644
--- a/graphics/x11drv/dib.c
+++ b/graphics/x11drv/dib.c
@@ -3079,10 +3079,11 @@ INT X11DRV_DIB_GetDIBits(
   {
      descr.ySrc = startscan;
   }
-
+#ifdef HAVE_LIBXXSHM
   if (dib)
     descr.useShm = (dib->shminfo.shmid != -1);
   else
+#endif
     descr.useShm = FALSE;
 
   EnterCriticalSection( &X11DRV_CritSection );
@@ -3176,7 +3177,11 @@ static void X11DRV_DIB_DoUpdateDIBSection(BITMAPOBJ *bmp, BOOL toDIB)
   descr.yDest     = 0;
   descr.width     = bmp->bitmap.bmWidth;
   descr.height    = bmp->bitmap.bmHeight;
+#ifdef HAVE_LIBXXSHM
   descr.useShm = (dib->shminfo.shmid != -1);
+#else
+  descr.useShm = FALSE;
+#endif
 
   if (toDIB)
     {
@@ -3388,6 +3393,7 @@ static int XShmErrorHandler(Display *dpy, XErrorEvent *event)
  *
  */
 
+#ifdef HAVE_LIBXXSHM
 extern BOOL X11DRV_XShmCreateImage(XImage** image, int width, int height, int bpp,
 		                                   XShmSegmentInfo* shminfo)
 {
@@ -3435,7 +3441,7 @@ extern BOOL X11DRV_XShmCreateImage(XImage** image, int width, int height, int bp
     }
     return FALSE;
 }
-
+#endif /* HAVE_LIBXXSHM */
 
  
 
@@ -3557,6 +3563,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
   /* Create XImage */
   if (dib && bmp)
   {
+#ifdef HAVE_LIBXXSHM
       if (TSXShmQueryExtension(display) &&
           X11DRV_XShmCreateImage( &dib->image, bm.bmWidth, effHeight,
                                   bmp->bitmap.bmBitsPixel, &dib->shminfo ) )
@@ -3566,6 +3573,9 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
           XCREATEIMAGE( dib->image, bm.bmWidth, effHeight, bmp->bitmap.bmBitsPixel );
           dib->shminfo.shmid = -1;
       }
+#else
+      XCREATEIMAGE( dib->image, bm.bmWidth, effHeight, bmp->bitmap.bmBitsPixel );
+#endif
   }
   
   /* Clean up in case of errors */
@@ -3621,6 +3631,7 @@ void X11DRV_DIB_DeleteDIBSection(BITMAPOBJ *bmp)
 
   if (dib->image) 
   {
+#ifdef HAVE_LIBXXSHM
       if (dib->shminfo.shmid != -1)
       {
           TSXShmDetach (display, &(dib->shminfo));
@@ -3629,6 +3640,7 @@ void X11DRV_DIB_DeleteDIBSection(BITMAPOBJ *bmp)
           dib->shminfo.shmid = -1;
       }
       else
+#endif
           XDestroyImage( dib->image );
   }
   
diff --git a/include/x11drv.h b/include/x11drv.h
index 67a8bb4d3e2bbd5ac0afcdff6bfcd3ff3f5bf32c..fd0c5eef6f36f6760102c736bdc9129413fab917 100644
--- a/include/x11drv.h
+++ b/include/x11drv.h
@@ -226,8 +226,10 @@ typedef struct
     /* Selector for 16-bit access to bits */
     WORD selector;
 
+#ifdef HAVE_LIBXXSHM
     /* Shared memory segment info */
     XShmSegmentInfo shminfo;
+#endif
 
 } X11DRV_DIBSECTION;