Forwarding DLL
- From: Mihai P <m_pop_escu@xxxxxxxxx>
- Date: Wed, 28 Jun 2006 14:43:27 +0300
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 :)
.
- Follow-Ups:
- Re: Forwarding DLL
- From: Ulrich Eckhardt
- Re: Forwarding DLL
- Prev by Date: Is nmake.exe legally redistributable ?
- Next by Date: Re: fopen_s
- Previous by thread: Is nmake.exe legally redistributable ?
- Next by thread: Re: Forwarding DLL
- Index(es):
Relevant Pages
|