ok, how 'bout some linker errors? :)

2 views
Skip to first unread message

Nick Costa

unread,
Sep 22, 1998, 3:00:00 AM9/22/98
to
I feel ridiculous continuously posting, and i'm starting to think the
board's getting tired of it, but i must post anyway. My knowledge of linker
errors is not that vast. I am getting 14 linker errors. Each is on a
different occurrence, but they are all the same error: "Multiply defined".
Some are descriptor, some are data, and some are code.

I know I haven't defined each of these functions more than once, and surely
not in four or five files, as the linker is stating. I must be doing
something else wrong. Any insights or things to try? I would greatly
appreciate it.

Thanks again,
Nick

Steve Caine

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
If this stuff were easy, anybody could do it. ;-}

Without more specific examples, it's hard to know exactly what's going
wrong. A good technique is to recreate the problem in a minimal set of
code.

In this case, data variables might be declared in header files without
"extern", which means each source file including that header gets its
own "int foo". That's all I can suggest at the moment.

Keep at it. Eventually the light starts to dawn.


Nick Costa <njc...@aol.com> wrote:


--
Steve Caine, software engineer email: steve...@document.com
Document Directions Inc. http: www.document.com
Boston MA, USA

MW Ron

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
In article <njcosta-ya0240800...@news.earthlink.net>,
njc...@aol.com (Nick Costa) wrote:

> I feel ridiculous continuously posting, and i'm starting to think the
> board's getting tired of it, but i must post anyway. My knowledge of linker
> errors is not that vast. I am getting 14 linker errors. Each is on a
> different occurrence, but they are all the same error: "Multiply defined".
> Some are descriptor, some are data, and some are code.
>
> I know I haven't defined each of these functions more than once, and surely
> not in four or five files, as the linker is stating. I must be doing
> something else wrong. Any insights or things to try? I would greatly
> appreciate it.

You can't generate date in a header and include that header in more than
one source file. If you do a #define me 2 then in another file #define me
3 you get a redefintion error, If you have a header with a structure or
type in a header and it isn't static const or external you will have
problems like that.

What you have to do is put these type of things in a source file then
declare them external in the header. You can then use that header for many
source files without getting redefinition errors. One other thing to do
is put them in the Prefix file but that is not as portable as using the
keyword extern.

Ron

--
Specials on Renewals, New Purchases, Books and Bundles
http://www.metrowerks.com/products.qry?x=specials

METROWERKS Ron Liechty
"Software at Work" MW...@metrowerks.com

Kirk Swenson

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to

>I know I haven't defined each of these functions more than once, and surely
>not in four or five files, as the linker is stating. I must be doing
>something else wrong. Any insights or things to try? I would greatly
>appreciate it.

One of the simplest mistakes that leads to multiple definition warnings is
typing #include "myfile.c" or #include "myfile.cpp" when you meant to type
#include "myfile.h" in your include list in another source file. The
linker sees the definition of those items once when myfile is added to the
project and again when it's included in the other source file(s).
--
Kirk Swenson
Senior Software Engineer
Key Curriculum Press
kswe...@keypress.com

Reply all
Reply to author
Forward
0 new messages