Gcc problem on FC6

Markku Kolkka markkuk at tuubi.net
Tue Jun 19 12:57:18 UTC 2007


Les kirjoitti viestissään (lähetysaika tiistai 19 kesäkuu 2007):
> g++     GuiExample.cpp   -o GuiExample
> /tmp/cc2fblEI.o: In function `main':
> GuiExample.cpp:(.text+0x1e): undefined reference to
> `XOpenDisplay' GuiExample.cpp:(.text+0x102): undefined
> reference to
> `XCreateSimpleWindow'
...
You aren't linking with the X libraries containing the functions 
you need. Add "-lX11" to the command line.

> 	I have also tried using the basic make -k with the same
> results (no surprise).  So the question is, if the header is
> found and cpp works, then I suspect either link or ld as the
> culprits, but that would mean that the standard loader
> execution is messed up, because it should look in /usr/lib for
> the associated ".a" files that match the headers.

No, that's not how gcc works. You must add all other libraries 
than the standard C runtime on the compile/link command line. 
The include files don't contain any information telling the 
linker where to find the actual code implementing any external 
functions declared in the header.

> When I look 
> in /lib/X11, the only file there is the error message
> database. What happened to the X libraries?

They are in /usr/lib (or /usr/lib64).

-- 
 Markku Kolkka
 markku.kolkka at iki.fi




More information about the fedora-list mailing list