Why do I get this linker error in an assembly

R

Ralf Jablonski

Help !

I have created a Visual C++ class library (.net assembly) project with two
classes
named Base and Derived where Derived inherits from Base.
During link I get the following linker error:

Test.obj : error LNK2001: Unresolved external symbol "void __cdecl
__CxxCallUnwindDtor(void (__thiscall*)(void *),void *)"
(?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)

If I disable exception handling for the compiler (remove /EHsc) then the
assembly is created.
Is exception handling not allowed with inheritance in C++ ?

I'm looking for this issue over a week and found no solution.
Does nobody else run in this linker error ???

Here is the simplest example code:

#pragma once
using namespace System;
namespace Test
{
public __gc class Base
{
public:
Base(void){}
~Base(void){}
};

public __gc class Derived : public Base
{
public:
Derived(void){}
~Derived(void){}
};
}
 
T

Tomas Restrepo \(MVP\)

Ralf,
I have created a Visual C++ class library (.net assembly) project with two
classes
named Base and Derived where Derived inherits from Base.
During link I get the following linker error:

Test.obj : error LNK2001: Unresolved external symbol "void __cdecl
__CxxCallUnwindDtor(void (__thiscall*)(void *),void *)"
(?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)

If I disable exception handling for the compiler (remove /EHsc) then the
assembly is created.
Is exception handling not allowed with inheritance in C++ ?

I'm looking for this issue over a week and found no solution.
Does nobody else run in this linker error ???

Can you show us the exact command lines you're building with?

I tried repro'ing this with your example, and couldn't. It sure built OK
without /EHsc, I got a different error, but with it adding msvcrt[d].lib to
the linking libraries list resolved the issue.
 
R

Ralf Jablonski

Hello Tomas,
thanks very much for your tip.
If I add msvcrt[d].lib to the asm, the external is resolved.
I go on without /EHsc switch and use the allowed exception handling syntax
of .NET.
Thanks again :)
Ralf

Tomas Restrepo (MVP) said:
Ralf,
I have created a Visual C++ class library (.net assembly) project with two
classes
named Base and Derived where Derived inherits from Base.
During link I get the following linker error:

Test.obj : error LNK2001: Unresolved external symbol "void __cdecl
__CxxCallUnwindDtor(void (__thiscall*)(void *),void *)"
(?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)

If I disable exception handling for the compiler (remove /EHsc) then the
assembly is created.
Is exception handling not allowed with inheritance in C++ ?

I'm looking for this issue over a week and found no solution.
Does nobody else run in this linker error ???

Can you show us the exact command lines you're building with?

I tried repro'ing this with your example, and couldn't. It sure built OK
without /EHsc, I got a different error, but with it adding msvcrt[d].lib to
the linking libraries list resolved the issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top