Discussion:
VC++ 2019 error "one or more multiply defined symbols found" ...
(too old to reply)
Russell Potter
2019-11-20 00:29:51 UTC
Permalink
My program compiles OK, but ends with the fatal error
"LNK1169: one or more multiply defined symbols found" -
with,however, no indication as to the names of these
symbols.

Would somebody be able to tell me how I might be able to
go about finding this information?

hanks,
Russell
Kaz Kylheku
2019-11-20 01:15:13 UTC
Permalink
Post by Russell Potter
My program compiles OK, but ends with the fatal error
"LNK1169: one or more multiply defined symbols found" -
with,however, no indication as to the names of these
symbols.
If true, that must be a major regression in the Microsoft toolchain. I
worked as a Win32 developer for many years, and don't recall having a
problem identifying unresolved symbols.

Thompson and Ritchie working on Unix in 1977 almost certainly made
themselves a linker that told them which symbols were unresolved.

(Well, maybe not; Ritchie liked utilities that print

?

when there is an error, or just return a failed exit status with
no output, just to keep you on your toes.)
Post by Russell Potter
Would somebody be able to tell me how I might be able to
go about finding this information?
Suppose I'm given a toolchain which absolutely will not provide this
information, no matter what.

The next thing I would do is look through the header files for places
where instead of writing a declaration, I wrote a definition. For
instance,

// globals.h

extern int g_frobosity_level = 0; // oops: definition!

Or other similar problems, like a missing inline on a function.

In C++, there are some C++ specific ways to cause this sort
of problem.

Then I'd comb through the program modules and find any local
symbols that are not properly static.

I'd also compare the differences between my work and the closest version
of the program that built. If you checked out a building, working
program from version control, and it doesn't build with the changes you
made, then suspect your changes: review what you have in "git diff".
Russell Potter
2019-11-20 04:46:44 UTC
Permalink
Kaz,

Thanks for taking the trouble to respond
to my post :-)
Post by Kaz Kylheku
In C++, there are some C++ specific ways
to cause this sort of problem
Don't know if it makes any difference,
but my program is written in C, not C++,
BTW :-)

Now (my C is a bit rusty, and my code is
littered with this type of statement), if
Post by Kaz Kylheku
static int a,
b,
< c;

Will all three declarations be static,
or just the first one? If the latter, this
would explain the source of my problem: (i.e.
many, potentially duplicate, non-static
globals) but how should I re-write it so all
will be static?

Would I have to write
Post by Kaz Kylheku
static int a;
static int b;
static int c;
Which seems a bit "clunky" to me, or is
there a better way?

Russell
Kaz Kylheku
2019-11-20 21:24:08 UTC
Permalink
Post by Russell Potter
Kaz,
Thanks for taking the trouble to respond
to my post :-)
Post by Kaz Kylheku
In C++, there are some C++ specific ways
to cause this sort of problem
Don't know if it makes any difference,
but my program is written in C, not C++,
BTW :-)
Now (my C is a bit rusty, and my code is
littered with this type of statement), if
Post by Kaz Kylheku
static int a,
b,
< c;
Will all three declarations be static,
or just the first one?
No, all three. That's not it.
Russell Potter
2019-11-21 07:19:33 UTC
Permalink
Kaz,
Post by Kaz Kylheku
No, all three. That's not it
So, alternatively, how would I go
about listing the non-static,
global symbols of a project in VC++
2019?

Russell
Kaz Kylheku
2019-11-21 17:53:44 UTC
Permalink
Post by Russell Potter
Kaz,
Post by Kaz Kylheku
No, all three. That's not it
So, alternatively, how would I go
about listing the non-static,
global symbols of a project in VC++
2019?
Hmm. One way would be to look at the .OBJ files with DUMPBIN.EXE.

https://docs.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=vs-2019
Russell Potter
2019-11-22 04:55:19 UTC
Permalink
Kaz,
Post by Kaz Kylheku
Hmm. One way would be to look at the .OBJ files
with DUMPBIN.EXE
Trouble is, I can't seem to find "dumpbin" on my
machine: do you know a URL from which I might be
able to download it?(since I came up empty in my
fumbling efforts to Google it for it myself :-(

Russell
Kaz Kylheku
2019-11-22 06:02:09 UTC
Permalink
Post by Russell Potter
Kaz,
Post by Kaz Kylheku
Hmm. One way would be to look at the .OBJ files
with DUMPBIN.EXE
Trouble is, I can't seem to find "dumpbin" on my
machine: do you know a URL from which I might be
able to download it?(since I came up empty in my
fumbling efforts to Google it for it myself :-(
Hmm ...

https://stackoverflow.com/questions/477387/cannot-find-dumpbin-exe
--
TXR Programming Lanuage: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
Russell Potter
2019-11-23 11:56:25 UTC
Permalink
Kaz,
Post by Kaz Kylheku
https://stackoverflow.com/questions/477387/cannot-find-dumpbin-exe
--
TXR Programming Lanuage: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
Well, I appear to have solved the immediate problem
by excluding the file from my project that I'd assumed
had contained the problematic duplicate symbols,
since I'd only had this trouble since it'd seen added:
and this assumption turned out to have been correct:

but thanks for your help, anyway :-)

Russell

Loading...