X11/Xlib.h not found in Ubuntu

后端 未结 4 406
-上瘾入骨i
-上瘾入骨i 2021-01-30 06:09

I\'m trying to write a rather trivial program using open gl on linux, but at a compile time it says:

Compile thumb : egl <= cuberenderer.c In file i

相关标签:
4条回答
  • 2021-01-30 06:45

    Presume he's using the tutorial from http://www.arcsynthesis.org/gltut/ along with premake4.3 :-)

    sudo apt-get install libx11-dev ................. for X11/Xlib.h
    sudo apt-get install mesa-common-dev........ for GL/glx.h
    sudo apt-get install libglu1-mesa-dev ..... for GL/glu.h
    sudo apt-get install libxrandr-dev ........... for X11/extensions/Xrandr.h
    sudo apt-get install libxi-dev ................... for X11/extensions/XInput.h

    After which I could build glsdk_0.4.4 and examples without further issue.

    0 讨论(0)
  • 2021-01-30 06:52

    A quick search using...

    apt search Xlib.h
    

    Turns up the package libx11-dev but you shouldn't need this for pure OpenGL programming. What tutorial are you using?

    You can add Xlib.h to your system by running the following...

    sudo apt install libx11-dev
    
    0 讨论(0)
  • 2021-01-30 07:03

    Andrew White's answer is sufficient to get you moving. Here's a step-by-step for beginners.

    A simple get started:

    Create test.cpp: (This will be built and run to verify you got things set up right.)

    #include <X11/Xlib.h>
    #include <unistd.h>
    
    
    main()
    {
      // Open a display.
      Display *d = XOpenDisplay(0);
    
      if ( d )
        {
          // Create the window
          Window w = XCreateWindow(d, DefaultRootWindow(d), 0, 0, 200,
                       100, 0, CopyFromParent, CopyFromParent,
                       CopyFromParent, 0, 0);
    
          // Show the window
          XMapWindow(d, w);
          XFlush(d);
    
          // Sleep long enough to see the window.
          sleep(10);
        }
      return 0;
    }
    

    (Source: LinuxGazette)

    Try: g++ test.cpp -lX11 If it builds to a.out, try running it. If you see a simple window drawn, you have the necessary libraries, and some other root problem is afoot.

    If your response is:

        test.cpp:1:22: fatal error: X11/Xlib.h: No such file or directory
        compilation terminated.
    

    you need to install X11 development libraries. sudo apt-get install libx11-dev

    Retry g++ test.cpp -lX11

    If it works, you're golden.

    Tested using a fresh install of libX11-dev_2%3a1.5.0-1_i386.deb

    0 讨论(0)
  • 2021-01-30 07:09

    Why not try find /usr/include/X11 -name Xlib.h

    If there is a hit, you have Xlib.h

    If not install it using sudo apt-get install libx11-dev

    and you are good to go :)

    0 讨论(0)
提交回复
热议问题