Solved

gcc not working

Posted on 2002-04-04
14
721 Views
Last Modified: 2012-05-04
I have installed gcc's c compiler ( package downloaded and added). I tested it . It is working fine from last 2 months. now suddenly it giving error. when i compile any c file
$ gcc test.c

ld.so.1: /usr/ccs/bin/ld: fatal: relocation error: file /usr/ccs/lib/libld.so.2: symbol _elf_getxoff: referenced symbol not found
gcc: Internal compiler error: program ld got fatal signal 9

what is wrong ? I reinstalled the package. but still it is giving the same error why? please help...
thank u.
0
Comment
Question by:rama_krishna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
14 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6919749
This is a Solaris system, right? What version?

Have you made any changes in the system recently, other than to re-install gcc?

What's happening is that when gcc has compiled your code it then invokes Sun's ld program to link the object code and libraries. ld is complaining that it can't find a particular symbol in /usr/ccs/li/libld.so.2. In fact, that reference is actually a symbolic link to /usr/lib/libld.so.2. Check to be sure that the target of the link is still there. I'd think you'd get a different error if it was missing, but...
0
 

Author Comment

by:rama_krishna
ID: 6919965
OS is intel sun solaris 2.6. I have not made any changes to the system recently. /usr/ccs/li/libld.so.2 is there which is linked to /usr//lib/libld.so.2 ( which is also present).
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6920388
please post result when you call gcc with -v option
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rama_krishna
ID: 6930924
When i do
@gcc -v file1.c
the output is
gcc -v test1.c
Reading specs from /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/specs
gcc version 2.8.1
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=8 -Dunix -D__svr4__ -D__SVR4 -Dsun -D__unix__ -D__svr4__ -D__SVR4 -D__sun__ -D__unix -D__sun -Asystem(svr4) -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) test1.c /var/tmp/ccsTOQt_.i
GNU CPP version 2.8.1 (i386 System V Release 4)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/i386-pc-solaris2.6/include
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/cc1 /var/tmp/ccsTOQt_.i -quiet -dumpbase test1.c -version -o /var/tmp/ccsTOQt_.s
GNU C version 2.8.1 (i386-pc-solaris2.6) compiled by GNU C version 2.8.1.
 /usr/ccs/bin/as -V -Qy -o /var/tmp/ccsTOQt_1.o /var/tmp/ccsTOQt_.s
as: WorkShop Compilers 4.2 alpha 14 Jun 1996
 /usr/ccs/bin/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crt1.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crti.o /usr/ccs/lib/values-Xa.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtbegin.o -L/usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1 -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib /var/tmp/ccsTOQt_1.o -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtend.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtn.o
ld: Software Generation Utilities - Solaris-ELF (4.0)
Undefined                       first referenced
 symbol                             in file
sqlcxt                              /var/tmp/ccsTOQt_1.o
ld: fatal: Symbol referencing errors. No output written to a.out
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6932146
very simple:
  you have a reference to sqlcxt  (variable or procedure) somewhere in your test1.c

Either remove this reference (if possible), or specify the lib where to find it using the -l option.
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6932278
Hmm, I wonder if the problem all along has been a messed up LD_LIBRARY_PATH. Obviously, as ahoffmann has noted, that C code is refernencing functions that aren't in any of the standard GCC or system libraries, probably some SQL function.

What is LD_LIBRARY_PATH set to ('echo $LD_LIBRARY_PATH' should tell)?

What happens if you try to compile:

#include <stdio.h>
main(){printf("Welcome to my nightmare\n");}
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6932308
hmm, I know that Sun's bundled ld evaluate LD_LIBRARY_PATH for finding libs (if not told to do otherwise), but there was no lib given on command line, and sqlcxt is not a symbol in any lib linked against by default.
0
 

Author Comment

by:rama_krishna
ID: 6932976
yes that program contains one sql statement. Even normal c programm is also not running.
my c programme is
#######
#include <stdio.h>
main(){
printf("Hello world");
}

The error i got after $ gcc -v test.c
is
Reading specs from /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/specs
gcc version 2.8.1
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=8 -Dunix -D__svr4__ -D__SVR4 -Dsun -D__unix__ -D__svr4__ -D__SVR4 -D__sun__ -D__unix -D__sun -Asystem(svr4) -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) anil.c /var/tmp/cc0088fq.i
GNU CPP version 2.8.1 (i386 System V Release 4)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/i386-pc-solaris2.6/include
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/cc1 /var/tmp/cc0088fq.i -quiet -dumpbase anil.c -version -o /var/tmp/cc0088fq.s
GNU C version 2.8.1 (i386-pc-solaris2.6) compiled by GNU C version 2.8.1.
 /usr/ccs/bin/as -V -Qy -o /var/tmp/cc0088fq1.o /var/tmp/cc0088fq.s
as: WorkShop Compilers 4.2 alpha 14 Jun 1996
 /usr/ccs/bin/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crt1.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crti.o /usr/ccs/lib/values-Xa.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtbegin.o -L/usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1 -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib /var/tmp/cc0088fq1.o -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtend.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtn.o
ld: Software Generation Utilities - Solaris-ELF (4.0)
ld.so.1: /usr/ccs/bin/ld: fatal: relocation error: file /usr/ccs/lib/libld.so.2: symbol _elf_getxoff: referenced symbol not found
gcc: Internal compiler error: program ld got fatal signal 9
0
 

Author Comment

by:rama_krishna
ID: 6932977
yes that program contains one sql statement. Even normal c programm is also not running.
my c programme is
#######
#include <stdio.h>
main(){
printf("Hello world");
}

The error i got after $ gcc -v test.c
is
Reading specs from /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/specs
gcc version 2.8.1
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=8 -Dunix -D__svr4__ -D__SVR4 -Dsun -D__unix__ -D__svr4__ -D__SVR4 -D__sun__ -D__unix -D__sun -Asystem(svr4) -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) anil.c /var/tmp/cc0088fq.i
GNU CPP version 2.8.1 (i386 System V Release 4)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/i386-pc-solaris2.6/include
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/cc1 /var/tmp/cc0088fq.i -quiet -dumpbase anil.c -version -o /var/tmp/cc0088fq.s
GNU C version 2.8.1 (i386-pc-solaris2.6) compiled by GNU C version 2.8.1.
 /usr/ccs/bin/as -V -Qy -o /var/tmp/cc0088fq1.o /var/tmp/cc0088fq.s
as: WorkShop Compilers 4.2 alpha 14 Jun 1996
 /usr/ccs/bin/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crt1.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crti.o /usr/ccs/lib/values-Xa.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtbegin.o -L/usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1 -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib /var/tmp/cc0088fq1.o -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtend.o /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/crtn.o
ld: Software Generation Utilities - Solaris-ELF (4.0)
ld.so.1: /usr/ccs/bin/ld: fatal: relocation error: file /usr/ccs/lib/libld.so.2: symbol _elf_getxoff: referenced symbol not found
gcc: Internal compiler error: program ld got fatal signal 9
0
 
LVL 40

Expert Comment

by:jlevie
ID: 6933040
The way I see the error when using the simple test program it sure looks like a problem with the system environment. Unfortunately I don't have any 2.6 x86 boxes to look at so I can't tell you what the file sizes for the libs should be.

You could try compiling the test program statically with 'gcc -static test.c'. If the problem is only with one of the dynamic libs, which is what the error indicates, the static link should work. That would also tend to eliminate gcc as being the cause of the problem.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6933425
> gcc version 2.8.1
hmm I'm also not failar with x386 Solaris and gcc, but try to update to gcc 2.95.3

Another try: what does following tell you:
   ldd /usr/ccs/lib/libld.so.2
0
 

Author Comment

by:rama_krishna
ID: 6933647
I add a patch 107734-09 (downloaded from sun site). This patch is for linker problems. Now the problem has been solved.
Thank u all.........
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7833589
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ & refund points

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster (I don't work here, I'm just an Expert :-)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7909003
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question