0

I've been trying to debug and compile my C++ with Xlib code in CodeLite for a while now, but I can't seem to pass the -lX11 argument to the gcc compiler in CodeLite. How would I go about doing this (On Linux Ubuntu 16.04 LTS)?

Code:

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h> 
#include <X11/Xlib.h>

int main(int argc, char **argv){
    Display *display;
    XEvent event;
    Window win;
    int screen;
    bool running = true;

    display = XOpenDisplay(NULL);
    screen = DefaultScreen(display);
    win = XCreateSimpleWindow(display,XRootWindow(display,screen),100,100,500,300,1,XBlackPixel(display,screen),XWhitePixel(display,screen));
XMapWindow(display,win);

    while(running){
        XNextEvent(display,&event);
    }

}

Console Output:

----------Building project:[ Xlib - Debug ]----------
make[1]: Entering directory '/home/owner/Documents/C/Xlib'
/usr/bin/g++ -o ./Debug/Xlib @"Xlib.txt" -L.
./Debug/main.cpp.o: In function `main':
/home/owner/Documents/C/Xlib/main.cpp:14: undefined reference to `XOpenDisplay'
/home/owner/Documents/C/Xlib/main.cpp:16: undefined reference to `XWhitePixel'
/home/owner/Documents/C/Xlib/main.cpp:16: undefined reference to `XBlackPixel'
/home/owner/Documents/C/Xlib/main.cpp:16: undefined reference to `XRootWindow'
/home/owner/Documents/C/Xlib/main.cpp:16: undefined reference to `XCreateSimpleWindow'
/home/owner/Documents/C/Xlib/main.cpp:17: undefined reference to `XMapWindow'
/home/owner/Documents/C/Xlib/main.cpp:20: undefined reference to `XNextEvent'

Thanks in advance.

Logan Darby
  • 145
  • 16
  • `ProjectSettings -> Linker -> Libraries.` Add `-lX11` there. – Brandon Sep 05 '16 at 18:50
  • Cool, after messing about I figured out to not put -lX11 in Libraries, but Linker Options. Thanks for the help! – Logan Darby Sep 06 '16 at 01:10
  • @LoganDarby In `ProjectSettings -> Linker -> Libraries` you just need to add `X11` without the `-l` (CodeLite will add it) – Eran Sep 06 '16 at 16:50

0 Answers0