Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

Trouble including the 'X11/Xlib.h' header file within CMake [duplicate]

$
0
0

I am not able to get the X11/Xlib.h header file included properly with CMake on CLion. Below is the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.15)project(X11 C)set(CMAKE_C_STANDARD 11)add_compile_options(-Wall -lX11)add_executable(X11 main.c)

And the main.c file:

#include <stdio.h>#include <stdlib.h>#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/Xos.h>int main(int argc, char **argv) {    Display *dpy = XOpenDisplay(NULL);    return EXIT_SUCCESS;}

The error is undefined reference to 'XOpenDisplay'. The -Wall flag works fine and I get the unused variable warning for this snippet. Lastly, I am able to compile main.c from the command line without any problem:

gcc main.c -lX11

Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>