cgccldlinuxbrew

gcc can't find -lX11


I've used linuxbrew to install gcc 5.3 on a machine on which I don't have sudo access. I now want to link with X11:

> gcc test.c -lX11
ld: cannot find -lX11

I've checked that libX11.so exists in /usr/lib64/ which is on the compiler's LIBRARY_PATH. If I use the system's gcc it works fine, but I need a newer version to compile my actual program.


Solution

  • According to this comment by a linuxbrew developer,

    linuxbrewed gcc removes /usr/lib64 from the library path because mixing system libraries with brewed libraries creates havoc.

    The solution is to brew install linuxbrew/xorg/xorg.