🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ken Corey Wed, 17 May 1995 00:00
Strange compiler results
#929
Author: Ken Corey
Date: Wed, 17 May 1995 00:00
50 lines
2435 bytes
I'm hoping someone can give me a few pointers here...

First, we're using SunOS 4.1.3U1, with Sun's CC compiler from SunPro 4.

We've got a (very) large library that we link our applications to.  Lately,
we've been getting "symbol undefined" when trying to link against it.

When nm++ is used, the symbols are in the library, but they have a 
'd' in front of them, instead of a 'D'.

I couldn't find what a 'd' stood for in the man pages or in answerbook.

I found a wierd way to make the errors go away, and was hoping that 
maybe someone could give me a clue why this works:

My header file was like this:

extern const char a[];
extern const char b[];
extern const char c[];
extern const char d[];
extern const char e[];
extern const char f[];

My .cc file was like this:
const char a[]          = "something";
const char b[]          = "something";
const char c[]          = "something";
extern const char d[]   = "something";
extern const char e[]   = "something";
extern const char f[]   = "something";

I was getting undefined symbol errors for a,b, and c, but not for d, e and f.

Anyway, on a whim, I added the .o file to the end of the compile statement like 
so:
CC -g ... file1.o file2.o -Lpath -llibs thefilename.o

I got duplicate symbols for d,e and f, and still undefined symbols for a, b and c.

I decided to put 'extern' in front of a, b and c.

All of a sudden, it started working.

What gives?

--
Ken Corey   exukenc@exu.ericsson.se 214/907-5841  Speaking for everyone...
 Real computer scientists don't program in assembler.  They don't write
 in anything less portable than a number two pencil.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads