Article View: alt.sys.sun
Article #929Strange compiler results
From: Ken Corey
Date: Wed, 17 May 1995 00:00
Date: Wed, 17 May 1995 00:00
50 lines
2435 bytes
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.
Technical Details
Message-ID:
<3pcqjc$14b@cnn.exu.ericsson.se>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6653,3384fee99426a4f7,start X-Google-Attributes: gidf6653,public X-Google-Thread: 147f4b,3384fee99426a4f7,start X-Google-Attributes: gid147f4b,public X-Google-Thread: fba7f,3384fee99426a4f7,start X-Google-Attributes: gidfba7f,public X-Google-Thread: f88e1,3384fee99426a4f7,start X-Google-Attributes: gidf88e1,public X-Google-Thread: f6cb1,3384fee99426a4f7,start X-Google-Attributes: gidf6cb1,public From: exukenc@exu.ericsson.se (Ken Corey) Subject: Strange compiler results Date: 1995/05/17 Message-ID: <3pcqjc$14b@cnn.exu.ericsson.se> X-Deja-AN: 102836331 organization: Ericsson North America, Inc. newsgroups: alt.sys.sun,comp.sources.sun.d,swnet.sys.sun,aus.sun-works,comp.sys.sun.misc