Article View: gnu.gcc.bug
Article #5937GCC-2.7.2.1 ==> undefined symbol
From: Ulf Lunde
Date: Fri, 31 Jan 1997 00:00
Date: Fri, 31 Jan 1997 00:00
74 lines
2786 bytes
2786 bytes
Variables of type "void" generate "undefined symbols"
in GCC 2.7.2.1 on SPARC/Solaris. Is this a bug or a feature?
See example below.
First, with GCC 2.6.3 ==> No problem:
-----8<-------start---------------------------------------------------------
freke% cat void.c
void c_void;
main()
{
printf("OK\n");
exit(0);
}
freke% gcc-2.6.3 -c void.c
freke% nm void.o | grep c_void
void.o:
[4] | 1| 0|OBJT |GLOB |0 |COMMON |c_void
freke% /usr/ccs/bin/ld void.o -lc
freke% a.out
OK
freke%
-----8<-------end-----------------------------------------------------------
Then, with GCC 2.7.2.1 ==> linking problem:
-----8<-------start---------------------------------------------------------
freke% gcc -V 2.7.2.1 -c void.c
freke% nm void.o | grep c_void
void.o:
[10] | 0| 0|NOTY |GLOB |0 |UNDEF |c_void
freke% /usr/ccs/bin/ld void.o -lc
Undefined first referenced
symbol in file
c_void void.o
ld: fatal: Symbol referencing errors. No output written to a.out
freke%
-----8<-------end-----------------------------------------------------------
I already have two workarounds for this problem.
1) Use the GNU linker which comes with Binutils:
-----8<-------start---------------------------------------------------------
freke% gcc -V 2.7.2.1 -c void.c
freke% nm void.o | grep c_void
void.o:
[10] | 0| 0|NOTY |GLOB |0 |UNDEF |c_void
freke% /usr/local/sparc-sun-solaris2.5.1/bin/gld void.o -e main -lc
freke% a.out
OK
freke%
-----8<-------end-----------------------------------------------------------
2) Use the -znodefs option to ld to suppress the error condition
(is this default for gld?):
-----8<-------start---------------------------------------------------------
freke% gcc -V 2.7.2.1 -c void.c
freke% nm void.o | grep c_void
void.o:
[12] | 0| 0|NOTY |GLOB |0 |UNDEF |c_void
freke% /usr/ccs/bin/ld -znodefs void.o -lc
freke% a.out
OK
freke%
-----8<-------end-----------------------------------------------------------
--
Ulf Lunde <ulflunde@pvv.org> http://www.pvv.org/~ulflunde/
Technical Details
Message-ID:
<ULFLUNDE.97Jan31181604@bigblue.pvv.ntnu.no>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,c593e94af3afef87,start X-Google-Attributes: gid113d02,public From: ulflunde@pvv.ntnu.no (Ulf Lunde) Subject: GCC-2.7.2.1 ==> undefined symbol Date: 1997/01/31 Message-ID: <ULFLUNDE.97Jan31181604@bigblue.pvv.ntnu.no> X-Deja-AN: 213558437 sender: bug-gcc-request@prep.ai.mit.edu followup-to: gnu.gcc.bug organization: Norwegian University of Science and Technology x-gateway: relay2.UU.NET from bug-gcc to gnu.gcc.bug; Fri, 31 Jan 1997 12:17:39 EST newsgroups: gnu.gcc.bug