0

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.

Vlad Firoiu
  • 987
  • 1
  • 8
  • 17

2 Answers2

1

use -L flag, like this -L/usr/lib64, or you can specify full path to library like this gcc test.c /usr/lib64/libX11.so

fghj
  • 8,898
  • 4
  • 28
  • 56
0

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.

Vlad Firoiu
  • 987
  • 1
  • 8
  • 17