Gcc problem on FC6

Les hlhowell at pacbell.net
Tue Jun 19 23:47:10 UTC 2007


On Wed, 2007-06-20 at 00:36 +0300, Markku Kolkka wrote:
> Les kirjoitti viestissään (lähetysaika tiistai 19 kesäkuu 2007):
> > So just to prove that this didn't change anything I tried:
> > gcc -L X11 GuiExample.cpp
> 
> The option is "-lX11", not "-L X11". Linux is case sensitive and 
> spaces are also significant.
> 
> > I am sorry, and this is probably clear to some of you, but I
> > am at a loss to understand why this doesn't work.  If I use
> > gcc, the presence or absence of a library .a or .so shouldn't
> > matter since the compiler should create the link chain based
> > on the extern definition, which could be resolved at load
> > time.
> 
> The extern definition doesn't tell which library contains the 
> symbol, just the function prototype or variable declaration. 
> _You_ must tell the compiler which libraries to link in order to 
> resolve the references.
> 
I wasn't aware that gcc had combined the linker with the precompiler and
compiler.  OK.  Here is the result with the lowercase l.  This did not
appear to work either, so I tried it in several combinations:

$ gcc -l/usr/lib/libX11.so GuiExample.cpp
/usr/bin/ld: cannot find -l/usr/lib/libX11.so
collect2: ld returned 1 exit status
$ gcc -l /usr/lib/libX11.so GuiExample.cpp
/usr/bin/ld: cannot find -l/usr/lib/libX11.so
collect2: ld returned 1 exit status
$ gcc -llibX11 GuiExample.cpp
/usr/bin/ld: cannot find -llibX11
collect2: ld returned 1 exit status


and here is the library:
$ ls /usr/lib/libX11*
/usr/lib/libX11.so  /usr/lib/libX11.so.6  /usr/lib/libX11.so.6.2.0

These are cut and pasted from the terminal window just as they appeared.

I was sure I had already tried this, but I wanted to make sure I didn't
miss it by mistake.  And to help you guys understand how perplexing this
is.

I'll wait for some more responses to see if there is a better solution.
I have really been spoiled by Sun's developer environment.  Kudos to
those guys.  

Now I know that GCC used to work a long time ago, and quite easily, so
it is something in my setup.  I also know that in the SUN environment I
had LD_LIBRARY_PATH set in the environment, which is not set here, and I
saw where someone said that was not required and in fact not good
practice, and the GCC documentation talks about a file in the lib path
that sets the default search, but I cannot find that file, either, and
that may be the problem.

But I am not sure the documentation is up to date, and since an earlier
program compiled correctly in Eclipse, but it was not a X program, and
since the missing library references appear to all be to the X platform
libraries, I think you and Peter are on the right track, but I am still
snowed.

Do any of you know how make and gcc get the path to the libraries?

Regards,
Les H




More information about the fedora-list mailing list