Forwarding DLL



I want to make a DLL to forward some classes from a LIB.

So, I have a solution in VS.NET2005 which contains 3 projects presented in their build order:

ForwardLib [Win32.Static Library -pch] ~ no reference
ForwardDll [Win32.DLL + Export Simbols] ~ reference to Lib
ForwardApp [Win32 Application] ~ reference to Dll

In ForwardLib I have MathFuncs class, it's header file is:

[MathFuncs.h]
#pragma once

#ifndef FORWARDDLL_API
#define FORWARDDLL_API
#endif

class FORWARDDLL_API MathFuncs
{
public:
MathFuncs(void);
public:
~MathFuncs(void);
public:
int add(int a, int b);
public:
int mul(int a, int b);
};
#EOF#

[MathFuncs.cpp]
#include "MathFuncs.h"

MathFuncs::MathFuncs(void)
{
}

MathFuncs::~MathFuncs(void)
{
}

int MathFuncs::add(int a, int b)
{
return a+b;
}

int MathFuncs::mul(int a, int b)
{
return a*b;
}
#EOF#

ForwardDll.h
#ifdef FORWARDDLL_EXPORTS
#define FORWARDDLL_API __declspec(dllexport)
#else
#define FORWARDDLL_API __declspec(dllimport)
#endif

#include "..\ForwardLib\MathFuncs.h"
#EOF#

In ForwardApp.h I added:
#include "..\ForwardDll\ForwardDll.h"


When I make no explicit calls of the imported class from the application everything is ok, but when I try to use it, even to create an object of that type linker shouts:

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall MathFuncs::~MathFuncs(void)" (__imp_??1MathFuncs@@QAE@XZ) referenced in function "int __cdecl InitInstance(struct HINSTANCE__ *,int)" (?InitInstance@@YAHPAUHINSTANCE__@@H@Z) ForwardApp.obj

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall MathFuncs::MathFuncs(void)" (__imp_??0MathFuncs@@QAE@XZ) referenced in function "int __cdecl InitInstance(struct HINSTANCE__ *,int)" (?InitInstance@@YAHPAUHINSTANCE__@@H@Z) ForwardApp.obj

I'm a bit confused about how linker exports my functions within the class from the dll though I think it doesnt do that at all. I looked in the binary dll file and I hadn't found any function symbol; just the class without any code; thus generating these link errors.
To my mind, the problem is when exporting/forwarding the class from DLL.
When I link a LIB to another project, the code from the lib is linked to the project as if I define&declare it there?
If so, the DLL should contain those symbols, but it doesn't and I cannot figure this out!

What I'm doing wrong? Is there another way?
Please help me with this! 10x a lot guys :)
.



Relevant Pages

  • Re: am having a problem with pinvoke and StringBuilder[ ]
    ... If you don't have the source of the DLL then you are in a world of pain, that means you wont be able to use the interop marshaler, you need to "custom" marshal. ... public static extern int EnumerateBoards(ref int numBoards, ... Since the String class is immutable, I have used StringBuilder in my code ...
    (microsoft.public.dotnet.framework.clr)
  • Problem in performance of calling a dialog in DLL(Windows programm
    ... I use VC++ 2008 and have two part in my project(First part: my dll project ... “Select Reader” and then select one of these substrings and send it to the ... int nPtr=0; ... static buff* pad=new buff; ...
    (microsoft.public.vc.mfc)
  • Problem in correct performance of calling a dialog in a DLL(Window
    ... I use VC++ 2008 and have two part in my project(First part: my dll project ... “Select Reader” and then select one of these substrings and send it to the ... int nPtr=0; ... static buff* pad=new buff; ...
    (microsoft.public.dotnet.languages.vc)
  • Problem in correct performance of calling a dialog in a DLL(Window
    ... I use VC++ 2008 and have two part in my project(First part: my dll project ... “Select Reader” and then select one of these substrings and send it to the ... int nPtr=0; ... static buff* pad=new buff; ...
    (microsoft.public.vc.language)
  • Re: am having a problem with pinvoke and StringBuilder[ ]
    ... DLL: Hello from TestLib.dll ... Since the String class is immutable, I have used StringBuilder in my code ... public static extern int EnumerateBoards(ref int numBoards, ...
    (microsoft.public.dotnet.framework.clr)