
Linking functions problems in dll
I've a problem importing same functions from a dll:
I've declared them in a header file (hookDLL.h) in this way:
#ifndef HOOKDLL_H
#define HOOKDLL_H
#ifndef HOOKLIBAPI
#define HOOKLIBAPI __declspec(dllimport)
#endif
HOOKLIBAPI BOOL WINAPI Hook_Start (HWND hWnd);
HOOKLIBAPI BOOL WINAPI Hook_Init (HWND hWnd);
HOOKLIBAPI BOOL WINAPI Hook_Stop ();
HOOKLIBAPI BOOL WINAPI Hook_Installed ();
#endif // HOOKDLL_H
I've implemented them into the implementation file (hookDLL.c):
#define HOOKLIBAPI __declspec(dllexport)
#include "hookDLL.h"
BOOL WINAPI Hook_Init (HWND hWnd)
{
m_hwndOut=hWnd;
return (m_hwndOut!=NULL);
Quote:
}
...
At this point the compiler build the dll and the .lib and .exp files
correctly.
Then I try to use them into the exe in this way:
#include "stdafx.h"
#include "Spyer.h"
#include "MainFrm.h"
#include "SpyerDoc.h"
#include "SpyerView.h"
#include ".\hookDLL\hookDLL.h"
...
void CSpyerView::OnHook()
{
if (Hook_Installed ()) {
AfxMessageBox("Terminare l'hook corrente prima di effettuare una nuova
cattura!",MB_ICONEXCLAMATION);
return;
}
Quote:
}
...
And now the linker says me:
Compiling...
StdAfx.cpp
Compiling...
MainFrm.cpp
Spyer.cpp
SpyerDoc.cpp
SpyerView.cpp
Generating Code...
Linking...
SpyerView.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) int __stdcall Hook_Init(struct HWND__ *)"
SpyerView.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) int __stdcall Hook_Start(struct HWND__ *)"
SpyerView.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) int __stdcall Hook_Installed(void)"
SpyerView.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) int __stdcall Hook_Stop(void)"
C:\WINDOWS\Desktop\Projects\Spyer\Debug\Spyer.exe : fatal error LNK1120: 4
unresolved externals
Error executing link.exe.
Spyer.exe - 5 error(s), 0 warning(s)
I link the project with the HookDLL.lib (obvious).
Can you tell me way? (if you want the complete code its size is 75 kb).
Perhaps the reason is I try to use function from a file wri{*filter*} in C in
another written in C++ ? (I've tried unsuccessfully to use extern "c", but I
wrong something).
Please Help!