4

I copy-past this code from Wikipedia: http://en.wikipedia.org/wiki/Xlib

And I'm getting this error:

fatal error C1083: Cannot open include file: 'X11/Xlib.h': No such file or directory

I assume it works for c++ even the though the code is c, or at least find the library x11?

Been stuck on this problem entire day... anyone have any idea what I'm doing wrong here?

Alice
  • 701
  • 1
  • 5
  • 17

3 Answers3

6

I'm assuming from your usage of Microsoft visual C++ that you are on a windows platform. Now, from http://en.wikipedia.org/wiki/X_Window_System referenced from http://en.wikipedia.org/wiki/Xlib:

Microsoft Windows is not shipped with support for X, but many third-party implementations exist, as free and open source software such as Cygwin/X, and proprietary products such as Exceed, MKS X/Server, Reflection X, X-Win32 and Xming.

This is why the compiler can't find the "X11/XLib.h" header. You would need to either install one of those implementations or otherwise use an abstraction layer such as one of those mentioned in http://en.wikipedia.org/wiki/Xlib (GTK+, Qt, SDL, ...)

SleuthEye
  • 14,379
  • 2
  • 32
  • 61
0

You have to install the X-Lib and X.org if you want to see something. Keep in mind, X11 is originally more common in/with Linux. However, I cannot advise to use the X-Lib anymore. Often it is strongly advisable to use Higher-Level-SDKs like Qt, GTK or WxWidgets. This has many advantages:

  • Less code required
  • More functionality included
  • Often OS independent
  • Embedding into Desktop Themes/Styles
dgrat
  • 2,214
  • 4
  • 24
  • 46
0

Windows doesn't use the X11 windowing system, and so the Xlib library isn't available.

What are you trying to do? Why do you feel that you need Xlib on Windows?

jalf
  • 243,077
  • 51
  • 345
  • 550
  • I'm reading this book: Computer Graphics: Principles and Practice. It uses a library called "SRGP" which includes the X11 library. – Alice Mar 09 '14 at 15:28
  • I wonder, this book is from year 1996 but it looks like it stucks in the 80s! Look for a better book. – dgrat Mar 10 '14 at 09:53
  • The book is still worth reading for the *theory*, for its explanations of computer graphics and rendering. But in terms of *code*, it is useless. Don't try to use compile the actual code from the book. Use it to understand the essentials of computer graphics, rendering and rasterization, and then write your code using a modern API. – jalf Mar 10 '14 at 10:20
  • Btw. X11 is OS independent and the library could be used on Windows. – dgrat Mar 11 '14 at 15:13
  • @dgrat sure, it could be, but it typically isn't used on Windows, and it requires a lot more plumbing than just linking to a library. – jalf Mar 11 '14 at 23:22