By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Managed C++ calling unmanaged C++ DLL - unresolved external symbol error

P: n/a
I have a managed C++ code which calls some methods in unmanaged C++
DLL.
In my unmanaged DLL, I have a PROTECTED virutal function in a base
class and derived class has a PRIVATE function which overrides the
virutal one in the base.
In my managed class, I have the following

private:
CUnmanaged __nogc* m_pUnManaged

constructor
ManagedApiWrapper::ManagedApiWrapper()
{
m_pUnManaged = new CUnmanaged();
}

void ManagedApiWrapper::managed_helloworld(String *msg)
{
m_pUnManaged-><func_a>;
}

The <func_ais from the derived class in that unmanaged DLL. I got
compiler error complaining on unresolved external symbol of that
protected virtual function in base class. The error will be gone if I
remove the <virtualfrom the base class function.

What could be causing the error?
Thanks.

Sep 21 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
gu**@hotmail.com wrote:
I have a managed C++ code which calls some methods in unmanaged C++
DLL.
In my unmanaged DLL, I have a PROTECTED virutal function in a base
class and derived class has a PRIVATE function which overrides the
virutal one in the base.
In my managed class, I have the following

private:
CUnmanaged __nogc* m_pUnManaged

constructor
ManagedApiWrapper::ManagedApiWrapper()
{
m_pUnManaged = new CUnmanaged();
}

void ManagedApiWrapper::managed_helloworld(String *msg)
{
m_pUnManaged-><func_a>;
}

The <func_ais from the derived class in that unmanaged DLL. I got
compiler error complaining on unresolved external symbol of that
protected virtual function in base class. The error will be gone if I
remove the <virtualfrom the base class function.

What could be causing the error?
Something doesn't' quite add up. "Unresolved external" is a linker error,
not a compiler error. So which is happening:

1. You get a linker error when building your managed DLL?
2. You get a linker error when building your unmanaged DLL?
3. You get a compiler error when building your managed DLL? In this case,
what's the exact error message?

Are any of the relevant functions of the unmanaged classes defined as inlie
(e.g. function body in the class definition)?

Which compiler are you using (7.0, 7;.1, 8.0)?

-cd
Sep 21 '06 #2

P: n/a
Sorry for the confusion. They were linker errors, not compiler errors.
I do not get any errors with UNmanaged DLL. I am getting Linker error
when building managed DLL complaining the protected virutal function in
the base class. The overriding function in the derived class is a
private function.

The unmanaged DLL 's base class does have some inline functions.

I am using C++ .NET, compiler 7.1.

Thanks.

Carl Daniel [VC++ MVP] wrote:
Something doesn't' quite add up. "Unresolved external" is a linker error,
not a compiler error. So which is happening:

1. You get a linker error when building your managed DLL?
2. You get a linker error when building your unmanaged DLL?
3. You get a compiler error when building your managed DLL? In this case,
what's the exact error message?

Are any of the relevant functions of the unmanaged classes defined as inlie
(e.g. function body in the class definition)?

Which compiler are you using (7.0, 7;.1, 8.0)?

-cd
Sep 21 '06 #3

P: n/a
gu**@hotmail.com wrote:
Sorry for the confusion. They were linker errors, not compiler errors.
I do not get any errors with UNmanaged DLL. I am getting Linker error
when building managed DLL complaining the protected virutal function
in
the base class. The overriding function in the derived class is a
private function.

The unmanaged DLL 's base class does have some inline functions.

I am using C++ .NET, compiler 7.1.
OK. Is the overriding function on the derived class inline? If it is, try
making it out of line. Is the constructor or destructor for the either
class (base or derived) inline? If it is, trying making them out of line.
Is the base class defined in a single header file, or is the definition
duplicated in two or more places? If the latter, make sure that the class
definitions are identical (or better yet, arrange for the definition to
appear in a single location).

-cd
Sep 21 '06 #4

P: n/a
Thanks for help.

But the overriding function in the derived class is NOT inline. The
constructors and destructors in both base and derived classes are NOT
inline. The base class is defined in ONE header file.

Some of the functions in the derived class do call those inline
functions in the base class, but not the one being complained by the
linker.

What else could possibly cause this error?
Thanks.

Carl Daniel [VC++ MVP] wrote:
>
OK. Is the overriding function on the derived class inline? If it is, try
making it out of line. Is the constructor or destructor for the either
class (base or derived) inline? If it is, trying making them out of line.
Is the base class defined in a single header file, or is the definition
duplicated in two or more places? If the latter, make sure that the class
definitions are identical (or better yet, arrange for the definition to
appear in a single location).

-cd
Sep 21 '06 #5

P: n/a
<gu**@hotmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Thanks for help.

But the overriding function in the derived class is NOT inline. The
constructors and destructors in both base and derived classes are NOT
inline. The base class is defined in ONE header file.

Some of the functions in the derived class do call those inline
functions in the base class, but not the one being complained by the
linker.

What else could possibly cause this error?
Hmmm. A good question! I'm trying to think of reasons why the managed DLL
would try to reference the name of the virtual function defined in the base
class, and I'm just about out of ideas.

I think the next thing I'd try is using dumpbin /symbols on all the .OBJ
files that go into the Managed DLL and find out which one is referencing the
problematic symbol, then work backwards from there to figure out what in the
source code is causing that reference.

-cd
Sep 21 '06 #6

P: n/a
Thanks so much for the help.

I will try to find out.
Carl Daniel [VC++ MVP] wrote:
Hmmm. A good question! I'm trying to think of reasons why the managed DLL
would try to reference the name of the virtual function defined in the base
class, and I'm just about out of ideas.

I think the next thing I'd try is using dumpbin /symbols on all the .OBJ
files that go into the Managed DLL and find out which one is referencing the
problematic symbol, then work backwards from there to figure out what in the
source code is causing that reference.

-cd
Sep 21 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.