How to fix GCC fatal error: X11/Xlib.h: No such file or directory on Ubuntu
Problem
While trying to compile a C/C++ software, you see an error message such as
x11_missing_error.txt
wmname.c:6:10: fatal error: X11/Xlib.h: No such file or directory
6 | #include <X11/Xlib.h>
| ^~~~~~~~~~~~
compilation terminated.Solution
You need to install the libx11-dev package:
install_libx11.sh
sudo apt install libx11-devThis package contains the necessary header files for X11 development.
After installing it, try to compile your software again.
Check out similar posts by category:
C/C++
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow