michiganalan
Programmer
Hi all,
I am trying to create a dll, to start with how dll works, I created a very simple dll as followed:
This is the maindll.cpp
#include "test.h"
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
int _stdcall adding(int x, int y)
{
int temp;
temp = perform(x,y);
//temp = x + y;
return temp;
}
while test.h includes:
int perform (int a, int b); // a function declaration
and test.c includes:
int perform (int a, int b) // a very simple function
{
return a + b;
}
I succesfully compile dll_main.cpp, test.c seperately. However, when I build the dll, I encountered
Creating library Debug/simple.lib and object Debug/simple.exp
simple.obj : error LNK2001: unresolved external symbol "int __cdecl perform(int,int)" (?perform@@YAHHH@Z)
Debug/simple.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
The most interesting thing is that I am able to create a working dll without test.h and test.c, whenever I tried to call functino from test.h, I encounted the linker error.
Thanks all
Alan
I am trying to create a dll, to start with how dll works, I created a very simple dll as followed:
This is the maindll.cpp
#include "test.h"
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
int _stdcall adding(int x, int y)
{
int temp;
temp = perform(x,y);
//temp = x + y;
return temp;
}
while test.h includes:
int perform (int a, int b); // a function declaration
and test.c includes:
int perform (int a, int b) // a very simple function
{
return a + b;
}
I succesfully compile dll_main.cpp, test.c seperately. However, when I build the dll, I encountered
Creating library Debug/simple.lib and object Debug/simple.exp
simple.obj : error LNK2001: unresolved external symbol "int __cdecl perform(int,int)" (?perform@@YAHHH@Z)
Debug/simple.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
The most interesting thing is that I am able to create a working dll without test.h and test.c, whenever I tried to call functino from test.h, I encounted the linker error.
Thanks all
Alan