CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2001
    Location
    Sweden
    Posts
    82

    Extension DLL problem

    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.

  2. #2
    Join Date
    Feb 2004
    Location
    San Diego, CA
    Posts
    14

    Re: Extension DLL problem

    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

  3. #3
    Join Date
    Nov 2004
    Location
    Virginia, The lovers' state
    Posts
    64

    Re: Extension DLL problem

    My guess is that you are forgetting to link with MyDll.Lib

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured