Re: Help: YDL 1.2.1 gcc compiler/linker generates wierd errors


Subject: Re: Help: YDL 1.2.1 gcc compiler/linker generates wierd errors
From: Kevin B. Hendricks (khendricks@ivey.uwo.ca)
Date: Sun May 27 2001 - 19:22:01 MDT


Hi,

Why are you statically linking with the Motif libraries?

They are not needed for your test program. Do you need to be linking with
libMrM and libXm (motif?) to get your linker error messages?

It works fine on my machine:

[kbhend@localhost kbhend]$ cat jjj1.c

#include <stdio.h>

int test1_fn();
int var1;

main() {
         int i;

         i = test1_fn();
         var1 = 10;
}
 
int test1_fn() {
         return 5;
}
[kbhend@localhost kbhend]$ cat jjj2.c
 
 
#include <stdio.h>
 
extern int test1_fn();
extern int var1;
 
test2_fn() {
         int i;
 
         i = test1_fn(); /* link error #1 occurs here */
         var1 = 10; /* link error #2 occurs here */
}
[kbhend@localhost kbhend]$ gcc -c jjj1.c
[kbhend@localhost kbhend]$ gcc -c jjj2.c
[kbhend@localhost kbhend]$ gcc -otest jjj1.o jjj2.o

No link errors.

If I then link it the way I think you meant to have it linked:

 gcc -otest jjj1.o jjj2.o -static /usr/X11R6/lib/libXm.a
/usr/X11R6/lib/libMrm.a -L/usr/X11R6/lib -lXt -lX11 -lICE -lXp

It also links fine.

So I can't recreate your problem at all.

Kevin

On Sunday 27 May 2001 15:47, D W wrote:
> Hello,
>
> I'm running YDL v1.2.1 on a PPC.
>
> When I try compiling and linking a test program using gcc,
> I'm getting various errors at link time and the link does not
> complete. (I also get the same linker errors if I try compiling
> using /usr/bin/cc ).
>
> Although the application being compiled consists of many
> .c and .h files, I can describe the problem using two small
> .c files:
>
>
> 1. file #1 : test1.c
>
> #include <stdio.h>
>
> int test1_fn();
> int var1;
>
>
> main() {
> int i;
>
> i = test1_fn();
> var1 = 10;
> }
>
> int test1_fn() {
> return 5;
> }
>
> _________________________
> 2. file #2 : test2.c
>
> #include <stdio.h>
>
> extern int test1_fn();
> extern int var1;
>
> test2_fn() {
> int i;
>
> i = test1_fn(); /* link error #1 occurs here */
> var1 = 10; /* link error #2 occurs here */
> }
>
>
> _________________________
> 3. Compile command:
>
> /usr/bin/gcc -o test test1.o test2.o \
> -static /usr/X11R6/lib/libMrm.a /usr/X11R6/lib/libXm.a \
> -L/lib \
> -lm -L/usr/X11R6/lib -lXt -lX11 \
>
>
> _________________________
> 4. Link errors:
>
> /home/test2.c:9: undefined reference to `test1_fn'
> /home/test2.c:9: relocation truncated to fit: R_PPC_REL24 test1_fn
> /home/test2.c:10: test2_fn: undefined reference to `var11'
>
>
> _________________________
> 5. Questions:
>
> What errors, if any, exist in the .c files or the compile
> command that would result in the errors:
>
> undefined reference
> relocation truncated to fit
>
> ??
>
> The actual app being compiled consists of many .c and .h
> files. Is there possibly some symbol table over-run taking
> place? If so, is there a way to increase the table size?
>
> Are there additional flags I could be trying in the compile/
> link command to resolve the link errors??
>
> Thanks in advance for any help on this.
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
>



This archive was generated by hypermail 2a24 : Sun May 27 2001 - 19:23:53 MDT