views:

493

answers:

1

i have a project where i need mouse hooks to be used, so i have added a MOUSE HOOK DLL project to my solution...on rebuild..i am getting the follwoing errors

Error 3 error LNK2005: "struct HHOOK__ * MyHook" (?MyHook@@3PAUHHOOK__@@A) already defined in projdialog.obj projdialogDlg.obj

Error 4 error LNK2005: "struct HINSTANCE__ * MyInstance" (?MyInstance@@3PAUHINSTANCE__@@A) already defined in projdialog.obj projdialogDlg.obj

Error 5 error LNK2019: unresolved external symbol "void __cdecl Hook(void)" (?Hook@@YAXXZ) referenced in function "public: void __thiscall CProjdialogDlg::OnLButtonDown(unsigned int,class CPoint)" (?OnLButtonDown@CProjdialogDlg@@QAEXIVCPoint@@@Z) projdialogDlg.obj

Error 6 error LNK2019: unresolved external symbol "void __cdecl Unhook(void)" (?Unhook@@YAXXZ) referenced in function "public: void __thiscall CProjdialogDlg::OnLButtonUp(unsigned int,class CPoint)" (?OnLButtonUp@CProjdialogDlg@@QAEXIVCPoint@@@Z) projdialogDlg.obj

Error 7 fatal error LNK1120: 2 unresolved externals .\Debug/projdialog.exe

A: 

1) "struct HHOOK__ * MyHook" (?MyHook@@3PAUHHOOK__@@A) already defined in projdialog.obj

Usually this error will occur , if that function is getting included twice by repeated inclusion of header files ,U can watch out for that (or) use this Linker option FORCE:MULTIPLE

2) Unresolved external symbol error. Compiler not able to find the function definitions of Hook & Unhook.

if it is defined in another file , include that header file. and add this on the top of the file where you are invoking the function. extern void __cdecl Unhook(void);

if it is a API and dll is implicitly linked. Add the .lib of the dll in additional dependencies.

WindowsPistha