Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
Hi All,

I'm using Xterm to try and write a basic program for the X Windows system that creates a window and draws a line. However, I can't compile the program in the following way:

g++ XWinCode.cc

The error I get is:

ld:Undefined Symbols:
_XCreateGC
_XCreateSimpleWindow
....etc

In my code I include <X11/Xlib.h>, <assert.h>, <unistd.h>. Using "locate" I know these files exist. What am I doing wrong? Thanks

Cheers,
ScKaSx
 

John Jacob

macrumors 6502a
Feb 11, 2003
548
9
Columbia, MD
ScKaSx said:
g++ XWinCode.cc

The error I get is:

ld:Undefined Symbols:
_XCreateGC
_XCreateSimpleWindow
....etc

You need to tell g++ which libraries to link to resolve these symbols.

Try
g++ XWinCode.cc -lX11

If that doesn't work then
g++ XWinCode.cc -L/usr/X11R6/lib -lX11
(replace /usr/X11R6/lib with the appropriate path to the X11 library files - I'm at work and don't have nmy PB with me so I can't say what the path is on a Mac).
 

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
Hi John,

Thanks the second one worked to perfection. Thanks again.

Cheers
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.