Compiling in Linux 15.10

Simon Lees simon at
Tue Feb 14 11:46:18 CST 2017

On 02/14/2017 11:19 AM, Michael Ritter wrote:
> To all,
> Does anyone know how to compile C++ code and link in the X11 library?
> I'm using :
>  g++ -Wall -L/usr/X11/lib -lX11 -m64 --std=c++11 -o prog1 xlib1.cpp
> and I get
> /tmp/ccVNWGzR.o: In function `main':
> xlib1.cpp:(.text+0xe): undefined reference to `XOpenDisplay'
> xlib1.cpp:(.text+0x6d): undefined reference to `XCreateWindow'
> xlib1.cpp:(.text+0x88): undefined reference to `XMapWindow'
> xlib1.cpp:(.text+0x94): undefined reference to `XFlush'
> collect2: error: ld returned 1 exit status
> in my very small C++ program.
> Thanks.
> Mike Ritter

That looks like it should be ok although you may not need
-L/usr/X11/lib, Basically the linker isn't finding those symbols. if you
run "pkg-config --libs x11" it will tell you the flags you need. On my
system it is just -lX11, but I have a completely different distro.



Simon Lees (Simotek)                  

Emergency Update Team                 
SUSE Linux                           Adelaide Australia, UTC+10:30
GPG Fingerprint: 5B87 DB9D 88DC F606 E489 CEC5 0922 C246 02F0 014B

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
Url : 

More information about the linuxsa mailing list