Click to See Complete Forum and Search --> : Extension DLL problem


NetMaster
February 7th, 2005, 09:21 AM
Hi,

I've created an extension dll (MyDll) to export a class. The header file in the dll looks like this:

// MyClass.h

class AFX_EXT_CLASS MyClass
{
public:
int GetValue();
...
};

In the application where I use the class I've added MyDll.lib to the linker's input library list (in the property pages) and included the same header MyClass.h in a .cpp file. In that file I have an object of the type MyClass where I call the function GetValue(). The problem is that when i try to compile the application I get a linker error:

unresolved external symbol public: int __thiscall MyClass::GetValue()

I can't figure out why I'm getting this error.

digwizf18
February 8th, 2005, 11:58 AM
Do you setup the project dependencies to ensure that the mydll is compiled first? I see this a lot where people setup the project properties correctly, but visual studio .Net doesn't automatically compile the dlls in the correct order. You have to setup the dependencies yourself and inform visual studio .Net that mydll must compile first (so that the .lib file is created). Select Project -> Project Dependencies from the main menu to set this up and ensure that mydll is compiled first. This assumes that you have a solution that contains all the projects and dlls that the project links to.

Another thing to check in your project settings is to ensure that your application project (or other dlls) are looking in the correct directory. so for mydll, under configuration properties -> General the output directory should be the same directory that the application project's linker input is pointing to. When you specify the linker input, you should specify the relative path (such as ../debug/mydll.lib or wherever it needs to point).

Those are the two things that I see trip people up quite often.

Hope that helps. Let us know if you are still having problems and perhaps someone else can offer another solution.

Regards,
Shawn

raghuvamshi
February 8th, 2005, 12:07 PM
My guess is that you are forgetting to link with MyDll.Lib