LINKER ERROR 1215

  • Thread starter Thread starter Peter Oliphant
  • Start date Start date
P

Peter Oliphant

For some reson my code is generating a LNK1215 error, which 'suggests' I
re-install VS C++. So I did. which did NOT solve the problem. The weid part
is it seems to be caused by my one CPP file, but not sure how. It compiled
just fine. Then I made a simple change and re-compiled, and got the 1215
error. After that I have to bring back in an old version of the code to make
it work again (not fun)...

This seems like a REAL LINKER error, not my cause.

Is this some known problem with the linker, and is there a solution?

Thanks in advance! : )
 
OK, got it down to where if I add a particular line it gets the linker
error, but if I comment it out it compiles. The line itself does not cause
the error, it's its existence (meaning the code is fine, in fact, this line
use to work before).

Maybe I have to actually REMOVE VS.NET 2003 and re-install from scratch?
Hate to do this and find out that's not the problem (it takes like 1.5 HOURS
to install)...

Should I contact MS? This is definitely a problem with THEIR linker...

I'll also go look to see if there is a service pack I don't know about... :)

HELP!!! I can't continue to program with this linker error...

[==P==]
 
Peter Oliphant said:
For some reson my code is generating a LNK1215 error, which 'suggests' I
re-install VS C++. So I did. which did NOT solve the problem. The weid
part is it seems to be caused by my one CPP file, but not sure how. It
compiled just fine. Then I made a simple change and re-compiled, and got
the 1215 error. After that I have to bring back in an old version of the
code to make it work again (not fun)...

This seems like a REAL LINKER error, not my cause.

Is this some known problem with the linker, and is there a solution?

No, it's not a linker problem, it's a real problem with your project. The
advise to reinstall VC++ is odd - I don't recall hearing of that ever fixing
the problem.

From what I understand, the main cause of this error is violations of the
One Definition Rule in C++. In other words, you have a thing (a class, for
example), that has more than a single definition.

A simple way to produce this error is to mix the class and struct keywords
on the same type. Under VC++ that results in two different types with
different decorated names, and will result in this error if you're
generating managed code. Could that be your problem?

-cd
 
A simple way to produce this error is to mix the class and struct keywords
on the same type. Under VC++ that results in two different types with
different decorated names, and will result in this error if you're
generating managed code. Could that be your problem?

Hmmm. Not sure. If it is, it's because the System::Math class has this
problem. I say this because if I remove the following line from my code it
compiles just fine:

double rad = Math::Atan2( 1, 2 ) ;

With it I get the problem (but not always, some states of my source code
allow compiling even with this line, which is odd as well). So, if it's a
violation of the One Definition Rule then its the Math calss that's doing it
(IMHO)! :)

[==P==]
 
BTW, the explanation for this error clearly says to re-install C++:

Linker Tools Error LNK1215
metadata operation failed (HRESULT) : error

The linker received an error from the .NET runtime while attempting to do a
metadata update through the .NET runtime.

HRESULT is the HRESULT from the .NET runtime method. error is the
..NET-supplied text.

You probably have a mismatched linker and .NET runtime; reinstall Visual
C++.



[==P==]
 
BTW, if LNK1215 is the result of two things being re-defined (which the
explanation for the error really doesn't say at all, it says it has a "bad
HRESULT due to a metadata update", which is extremely UNCLEAR if this means
its a re-define of some thing in my code), WHY in heck doesn't it say
something like "and the NAME of the thing re-defined is <such-and-such>"?
Obviously it knows the name of what was re-defined (or else it couldn't know
it was re-defined), so why doesn't it tell US this info? Why should we have
to figure out something it already knows? : )

[==P==]

Peter Oliphant said:
BTW, the explanation for this error clearly says to re-install C++:

Linker Tools Error LNK1215
metadata operation failed (HRESULT) : error

The linker received an error from the .NET runtime while attempting to do
a metadata update through the .NET runtime.

HRESULT is the HRESULT from the .NET runtime method. error is the
.NET-supplied text.

You probably have a mismatched linker and .NET runtime; reinstall Visual
C++.



[==P==]



Carl Daniel said:
No, it's not a linker problem, it's a real problem with your project.
The advise to reinstall VC++ is odd - I don't recall hearing of that ever
fixing the problem.

From what I understand, the main cause of this error is violations of the
One Definition Rule in C++. In other words, you have a thing (a class,
for example), that has more than a single definition.

A simple way to produce this error is to mix the class and struct
keywords on the same type. Under VC++ that results in two different
types with different decorated names, and will result in this error if
you're generating managed code. Could that be your problem?

-cd
 
Ok, it isn't the MATH class either (I've removed this line and caused it to
happen without it). It seems to do it 'randomly', in that it sometimes gives
this error, sometimes doesn't. And it happens when I add code that should
have no affect on such a thing. I mean, if I have a doubly define thing in
my program, why wouldn't it report it to me ALWAYS, not just when I add some
code that is not defining anything?

This is very frustrating since it isn't giving me the information I need to
fix this problem, and I'm can't work at all till I get this resolved. If it
is somehow my double-defining something, is there a way to get the complier
to tell me WHAT is being re-defined?

[==P==]


Peter Oliphant said:
BTW, if LNK1215 is the result of two things being re-defined (which the
explanation for the error really doesn't say at all, it says it has a "bad
HRESULT due to a metadata update", which is extremely UNCLEAR if this
means its a re-define of some thing in my code), WHY in heck doesn't it
say something like "and the NAME of the thing re-defined is
<such-and-such>"? Obviously it knows the name of what was re-defined (or
else it couldn't know it was re-defined), so why doesn't it tell US this
info? Why should we have to figure out something it already knows? : )

[==P==]

Peter Oliphant said:
BTW, the explanation for this error clearly says to re-install C++:

Linker Tools Error LNK1215
metadata operation failed (HRESULT) : error

The linker received an error from the .NET runtime while attempting to do
a metadata update through the .NET runtime.

HRESULT is the HRESULT from the .NET runtime method. error is the
.NET-supplied text.

You probably have a mismatched linker and .NET runtime; reinstall Visual
C++.



[==P==]



"Carl Daniel [VC++ MVP]"
For some reson my code is generating a LNK1215 error, which 'suggests'
I re-install VS C++. So I did. which did NOT solve the problem. The
weid part is it seems to be caused by my one CPP file, but not sure
how. It compiled just fine. Then I made a simple change and
re-compiled, and got the 1215 error. After that I have to bring back in
an old version of the code to make it work again (not fun)...

This seems like a REAL LINKER error, not my cause.

Is this some known problem with the linker, and is there a solution?

No, it's not a linker problem, it's a real problem with your project.
The advise to reinstall VC++ is odd - I don't recall hearing of that
ever fixing the problem.

From what I understand, the main cause of this error is violations of
the One Definition Rule in C++. In other words, you have a thing (a
class, for example), that has more than a single definition.

A simple way to produce this error is to mix the class and struct
keywords on the same type. Under VC++ that results in two different
types with different decorated names, and will result in this error if
you're generating managed code. Could that be your problem?

-cd
 
I guess I need to call Customer Support. Is there such a thing to solve
compiling problems? My company JUST ordered MSDN subscription so we get this
for free for a certain number of incidents/time-length, right?

This is why I can't solve the problem myself. I can add a function I don't
even call, does very little, and is definitely NOT named something I've
named something else, in fact, here is the line:

static double ABCXYZ( ) { return 0 ; }

and it generates the error with this line, and doesn't without it. This is
located in a class I call 'global_funcs' (where I store static functions I
wish to be able to access via delegates from anyplace in code). global_funcs
has other functions in it that work just fine.

How could adding this line POSSIBLY cause a LNK1215 error, since it goes
away if I remove it? I can call the function anything and it does this (not
just ABCXYZ). At the very least the linker is reporting the wrong problem or
its reporting a phantom error...

What should I do? I can't give you the code, its too big and it is
propietary...

[==P==]

Peter Oliphant said:
Ok, it isn't the MATH class either (I've removed this line and caused it
to happen without it). It seems to do it 'randomly', in that it sometimes
gives this error, sometimes doesn't. And it happens when I add code that
should have no affect on such a thing. I mean, if I have a doubly define
thing in my program, why wouldn't it report it to me ALWAYS, not just when
I add some code that is not defining anything?

This is very frustrating since it isn't giving me the information I need
to fix this problem, and I'm can't work at all till I get this resolved.
If it is somehow my double-defining something, is there a way to get the
complier to tell me WHAT is being re-defined?

[==P==]


Peter Oliphant said:
BTW, if LNK1215 is the result of two things being re-defined (which the
explanation for the error really doesn't say at all, it says it has a
"bad HRESULT due to a metadata update", which is extremely UNCLEAR if
this means its a re-define of some thing in my code), WHY in heck doesn't
it say something like "and the NAME of the thing re-defined is
<such-and-such>"? Obviously it knows the name of what was re-defined (or
else it couldn't know it was re-defined), so why doesn't it tell US this
info? Why should we have to figure out something it already knows? : )

[==P==]

Peter Oliphant said:
BTW, the explanation for this error clearly says to re-install C++:

Linker Tools Error LNK1215
metadata operation failed (HRESULT) : error

The linker received an error from the .NET runtime while attempting to
do a metadata update through the .NET runtime.

HRESULT is the HRESULT from the .NET runtime method. error is the
.NET-supplied text.

You probably have a mismatched linker and .NET runtime; reinstall Visual
C++.



[==P==]



"Carl Daniel [VC++ MVP]"
For some reson my code is generating a LNK1215 error, which 'suggests'
I re-install VS C++. So I did. which did NOT solve the problem. The
weid part is it seems to be caused by my one CPP file, but not sure
how. It compiled just fine. Then I made a simple change and
re-compiled, and got the 1215 error. After that I have to bring back
in an old version of the code to make it work again (not fun)...

This seems like a REAL LINKER error, not my cause.

Is this some known problem with the linker, and is there a solution?

No, it's not a linker problem, it's a real problem with your project.
The advise to reinstall VC++ is odd - I don't recall hearing of that
ever fixing the problem.

From what I understand, the main cause of this error is violations of
the One Definition Rule in C++. In other words, you have a thing (a
class, for example), that has more than a single definition.

A simple way to produce this error is to mix the class and struct
keywords on the same type. Under VC++ that results in two different
types with different decorated names, and will result in this error if
you're generating managed code. Could that be your problem?

-cd
 
Ok, this is what I think happened. My program started out originally as a
2002 project. We upgraded to 2003. When I tried to open the 2002 project in
2003 it warned me and then converted it. But I don't think the conversion
was perfect. Note this conversion was done weeks ago, not just before
problem happened.

I believe now this conversion was the culprit. Because to solve the problem
I just opened a NEW 2003 project, copied the source files over, added them
in, and now it compiles fine (so far...hehe)! : )

[==P==]

Peter Oliphant said:
I guess I need to call Customer Support. Is there such a thing to solve
compiling problems? My company JUST ordered MSDN subscription so we get
this for free for a certain number of incidents/time-length, right?

This is why I can't solve the problem myself. I can add a function I don't
even call, does very little, and is definitely NOT named something I've
named something else, in fact, here is the line:

static double ABCXYZ( ) { return 0 ; }

and it generates the error with this line, and doesn't without it. This is
located in a class I call 'global_funcs' (where I store static functions I
wish to be able to access via delegates from anyplace in code).
global_funcs has other functions in it that work just fine.

How could adding this line POSSIBLY cause a LNK1215 error, since it goes
away if I remove it? I can call the function anything and it does this
(not just ABCXYZ). At the very least the linker is reporting the wrong
problem or its reporting a phantom error...

What should I do? I can't give you the code, its too big and it is
propietary...

[==P==]

Peter Oliphant said:
Ok, it isn't the MATH class either (I've removed this line and caused it
to happen without it). It seems to do it 'randomly', in that it sometimes
gives this error, sometimes doesn't. And it happens when I add code that
should have no affect on such a thing. I mean, if I have a doubly define
thing in my program, why wouldn't it report it to me ALWAYS, not just
when I add some code that is not defining anything?

This is very frustrating since it isn't giving me the information I need
to fix this problem, and I'm can't work at all till I get this resolved.
If it is somehow my double-defining something, is there a way to get the
complier to tell me WHAT is being re-defined?

[==P==]


Peter Oliphant said:
BTW, if LNK1215 is the result of two things being re-defined (which the
explanation for the error really doesn't say at all, it says it has a
"bad HRESULT due to a metadata update", which is extremely UNCLEAR if
this means its a re-define of some thing in my code), WHY in heck
doesn't it say something like "and the NAME of the thing re-defined is
<such-and-such>"? Obviously it knows the name of what was re-defined (or
else it couldn't know it was re-defined), so why doesn't it tell US this
info? Why should we have to figure out something it already knows? : )

[==P==]

BTW, the explanation for this error clearly says to re-install C++:

Linker Tools Error LNK1215
metadata operation failed (HRESULT) : error

The linker received an error from the .NET runtime while attempting to
do a metadata update through the .NET runtime.

HRESULT is the HRESULT from the .NET runtime method. error is the
.NET-supplied text.

You probably have a mismatched linker and .NET runtime; reinstall
Visual C++.



[==P==]



"Carl Daniel [VC++ MVP]"
For some reson my code is generating a LNK1215 error, which
'suggests' I re-install VS C++. So I did. which did NOT solve the
problem. The weid part is it seems to be caused by my one CPP file,
but not sure how. It compiled just fine. Then I made a simple change
and re-compiled, and got the 1215 error. After that I have to bring
back in an old version of the code to make it work again (not fun)...

This seems like a REAL LINKER error, not my cause.

Is this some known problem with the linker, and is there a solution?

No, it's not a linker problem, it's a real problem with your project.
The advise to reinstall VC++ is odd - I don't recall hearing of that
ever fixing the problem.

From what I understand, the main cause of this error is violations of
the One Definition Rule in C++. In other words, you have a thing (a
class, for example), that has more than a single definition.

A simple way to produce this error is to mix the class and struct
keywords on the same type. Under VC++ that results in two different
types with different decorated names, and will result in this error if
you're generating managed code. Could that be your problem?

-cd
 
Peter said:
Ok, this is what I think happened. My program started out originally
as a 2002 project. We upgraded to 2003. When I tried to open the 2002
project in 2003 it warned me and then converted it. But I don't think
the conversion was perfect. Note this conversion was done weeks ago,
not just before problem happened.

I believe now this conversion was the culprit. Because to solve the
problem I just opened a NEW 2003 project, copied the source files
over, added them in, and now it compiles fine (so far...hehe)! : )

Glad to hear that you got it figured out. That does sound like a plausible
cause for the error. Is it possible that there was an .OBJ containing
managed code that wasn't being recompiled because of some mis-converted
setting?

It might also possible for settings to lead to ODR violations. I have no
idea if it was the case in your project, but the project conversion wizard
in 2002 and 2003 had bugs where it would mistakenly convert a project
setting into per-file settings. Subsequently, if you changed the project
setting, the change wouldn't be reflected to the converted files (but would
be reflected to newly added files). Among many other evils, that can lead
to ODR violations if various modules end up being compiled with, for
example, different #defines in effect.

-cd
 
Back
Top