Reputation: 23
I have a simple DLL that I am trying to compile in VS2010 Express. The code for the DLL is as follows:
#pragma comment(linker, "/EXPORT:PlusOne=_PlusOne@4")
#include <windows.h>
#include <commctrl.h>
extern "C" __declspec(dllexport) int PlusOne(int inNum)
{
inNum++;
return inNum;
};
extern "C" __declspec(dllexport) LRESULT CALLBACK OwnerDrawButtonProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
//further processing will go here
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
};
__stdcall is selected in the project options
The plusOne function on its own compiles fine but the second function does not.
DefSubclassProc is declared in commctrl.h but I get an error on the function, full error text including the libraries searched (which includes commdlg32 where this function lives) is below:
1> Searching libraries
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winmm.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1> Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1> Searching c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1>
1> Finished searching libraries
1>dlltest.obj : error LNK2001: unresolved external symbol _DefSubclassProc@16
1>s:\documents\my documents\visual studio 2010\Projects\dlltest\Release\dlltest.dll : fatal error LNK1120: 1 unresolved externals
It looks like it can't find the function but the library and header are present so I don't understand why.
As a small aside the motivation for the code is that I am subclassing a window in vba, but having the windowprocedure in vba is very unstable so I want to try and move it into a dll.
Please help me understand what is going wrong here.
Upvotes: 1
Views: 778
Reputation: 14467
"Comctl32.lib" (not "commdlg32.lib") is where this function "lives".
See MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/bb776403(v=vs.85).aspx
Upvotes: 3
Reputation: 258548
Have you tried linking against Comctl32.lib
?
The MSDN page says that's the library the function is located in.
Go to Project Settings -> Linker -> Input -> Additional dependencies and add Comctl132.lib
there.
Upvotes: 1