Re: Gcc problem on FC6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2007-06-18 at 22:20 -0700, Peter Gordon wrote:
> On Mon, 2007-06-18 at 21:59 -0700, Les wrote:
> > /tmp/cc2fblEI.o: In function `main':
> > GuiExample.cpp:(.text+0x1e): undefined reference to `XOpenDisplay'
> > GuiExample.cpp:(.text+0x102): undefined reference to
> > `XCreateSimpleWindow'
> > GuiExample.cpp:(.text+0x11f): undefined reference to `XSelectInput'
> > GuiExample.cpp:(.text+0x131): undefined reference to `XMapWindow'
> > GuiExample.cpp:(.text+0x153): undefined reference to `XCreateGC'
> > GuiExample.cpp:(.text+0x16f): undefined reference to `XSetForeground'
> > GuiExample.cpp:(.text+0x181): undefined reference to `XNextEvent'
> > GuiExample.cpp:(.text+0x1c4): undefined reference to `XDrawLine'
> > GuiExample.cpp:(.text+0x1cf): undefined reference to `XFlush'
> > collect2: ld returned 1 exit status
> > make: *** [GuiExample] Error 1
> > 
> 
> These look like linker errors; make sure you have the libX11-devel
> package installed and that your CXXFLAGS setting (if needed) includes
> the "-lX11" switch so that the linker can properly find the right shared
> library to link to.
> 
> > [...]
> > 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.
> 
> As an aside, Fedora's policy as I understand it is to explicitly exclude
> such static libraries from the packaging unless otherwise absolutely
> necessary. Once you install libX11-devel, you'll see various libX11.so
> symlinks in your /usr/lib directory (or /usr/lib64 if using a 64-bit
> arch). These are how the dynamic linker finds the appropriate library.
> 
> Hope that helped.
I appreciate your help Peter.  

I was sort of expecting that when I loaded the Eclipse environment that
it would bring along all the setup to use it.  I did have to add the
link to the java JRE for it to run, and I got past that hurdle, then
came to this one.  I decided to simplify by trying first gcc and then
make -k, So here I am.
Here is what happened when I tried installing libX11-devel:
# yum install libX11-devel
Loading "fedorakmod" plugin
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
Parsing package install arguments
Nothing to do


So just to prove that this didn't change anything I tried:
gcc -L X11 GuiExample.cpp
/tmp/ccOzTvpe.o: In function `main':
GuiExample.cpp:(.text+0x1e): undefined reference to `XOpenDisplay'
GuiExample.cpp:(.text+0x102): undefined reference to
`XCreateSimpleWindow'
GuiExample.cpp:(.text+0x11f): undefined reference to `XSelectInput'
GuiExample.cpp:(.text+0x131): undefined reference to `XMapWindow'
GuiExample.cpp:(.text+0x153): undefined reference to `XCreateGC'
GuiExample.cpp:(.text+0x16f): undefined reference to `XSetForeground'
GuiExample.cpp:(.text+0x181): undefined reference to `XNextEvent'
GuiExample.cpp:(.text+0x1c4): undefined reference to `XDrawLine'
GuiExample.cpp:(.text+0x1cf): undefined reference to `XFlush'
/tmp/ccOzTvpe.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

And then I tried this:
 yum whatprovides libX11.so
Loading "fedorakmod" plugin
Loading "installonlyn" plugin
Setting up repositories
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
Importing additional filelist information
filelists.xml.gz          100% |=========================| 1.2 MB
00:08     
dries     : ################################################## 3540/3540



libX11.i386                              1.0.3-4.fc6
core            
Matched from:
/usr/lib/libX11.so.6
/usr/lib/libX11.so.6.2.0
libX11.so.6



libX11-devel.i386                        1.0.3-4.fc6
core            
Matched from:
/usr/lib/libX11.so



libX11.i386                              1.0.3-4.fc6
core            
Matched from:
/usr/lib/libX11.so.6
/usr/lib/libX11.so.6.2.0
libX11.so.6



nx.i386                                  2.1.0-22.fc6
extras          
Matched from:
/usr/lib/nx/libX11.so.6
/usr/lib/nx/libX11.so.6.2



libX11.i386                              1.0.3-7.fc6
updates         
Matched from:
/usr/lib/libX11.so.6
/usr/lib/libX11.so.6.2.0
libX11.so.6



libX11.i386                              1.0.3-7.fc6
updates         
Matched from:
/usr/lib/libX11.so.6
/usr/lib/libX11.so.6.2.0
libX11.so.6



libX11-devel.i386                        1.0.3-7.fc6
updates         
Matched from:
/usr/lib/libX11.so



libX11.i386                              1.0.3-7.fc6
installed       
Matched from:
/usr/lib/libX11.so.6
/usr/lib/libX11.so.6.2.0
libX11.so.6



libX11-devel.i386                        1.0.3-7.fc6
installed       
Matched from:
/usr/lib/libX11.so


next I did
ls -al libX11*
lrwxrwxrwx 1 root root      15 Apr 12 09:35 libX11.so -> libX11.so.6.2.0
lrwxrwxrwx 1 root root      15 Apr 12 09:34 libX11.so.6 ->
libX11.so.6.2.0
-rwxr-xr-x 1 root root 1057916 Apr  9 15:12 libX11.so.6.2.0

so it looks like libX11.so is installed in /usr/lib. But:

gcc -LlibX11.so GuiExample.cpp
/tmp/cccbDnur.o: In function `main':
GuiExample.cpp:(.text+0x1e): undefined reference to `XOpenDisplay'
GuiExample.cpp:(.text+0x102): undefined reference to
`XCreateSimpleWindow'
GuiExample.cpp:(.text+0x11f): undefined reference to `XSelectInput'
GuiExample.cpp:(.text+0x131): undefined reference to `XMapWindow'
GuiExample.cpp:(.text+0x153): undefined reference to `XCreateGC'
GuiExample.cpp:(.text+0x16f): undefined reference to `XSetForeground'
GuiExample.cpp:(.text+0x181): undefined reference to `XNextEvent'
GuiExample.cpp:(.text+0x1c4): undefined reference to `XDrawLine'
GuiExample.cpp:(.text+0x1cf): undefined reference to `XFlush'
/tmp/cccbDnur.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

I then tried going to the add/remove software panel and adding more
libraries associated with development, but I was pretty sure I had the
required stuff, and sure enough it didn't change anything.

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.  Of course if I wanted to debug the code
statically, I would need the ".a" version of the library, but I don't
want that in this case.  I have downloaded and read the gcc manual, and
perused the man pages for both gcc and make.  

	Moreover the -L argument to gcc only invokes some printout of the
sym-link-times, which is not useful in this context.  Make tries to
interpret the -L instead of passing it to link or ld function, so it
simply doesn't change anything.  I know that make should have (does
have) a means to pass arguments to the link and ld processes, I haven't
gotten past the generic compile bit yet using gcc.

I can try to manually create a local make file, but due to my lapse in
time using make, I will a have to research that a bit first, and I am
not even sure that doing that will cure the problem.

I understand if there is a problem with linking, but I don't understand
why I have the cpp errors.

I have also removed the #include for the Xlib.h file and that gave me
more errors, which confirms that the compiler is finding the Xlib.h.  I
also checked the Xlib.h file and found that the procedures named in the
error all seem to have templates.  So when the compiler gives me an
undefined reference, typically I believe that it is due to a missing
header file, but that is not the case here.  I feel so stupid right now.
I have used C for ages, but for the last 15 years I have had my
environment setup on Sun and just used it.  When I retired, I wasn't
smart enough to save the details of how I had set it all up.  Where is
that notebook entry when you need it???  Oh, the one I forgot to
write!!!!

	I am using the predefined "everything including the kitchen sink" make
file, and I can't even find that file to use as an example.  The make
documentation I retrieved doesn't mention the location of the basic make
template file, and I wanted to use that to begin designing a local make
to see if I could code my way out of this in the make file. This is
where the modification to the CXXFLAGS environmental variable should go
anyway for X programs.  I will look online for another make example to
see if I can find one to cobble up for this little exercise.  But any
further help you might offer will be greatly appreciated.

Thanks for your help so far, Phillip.

Regards,
Les H


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux