Discussion:
Adding references to external DLLs
(too old to reply)
hs1290
2007-07-24 22:45:08 UTC
Permalink
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my project.bib
files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid() with a
prototype from hid.dll, along with necessary header files.
The project will not compile (before I even connect to the device):
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced in
function "int __cdecl GetHID(void)" (?GetHID@@YAHXZ)

How can I add a reference to hid.dll to make this error go away? I tried
adding a [DllImport("hid.dll")] statement, but got an error: error C2337:
'DllImport' : attribute not found.
voidcoder
2007-07-25 10:12:16 UTC
Permalink
You are confusing it with big brother windows desktop
I'm afraid. There is nothing like this on CE. Also not
clear what "hid.dll" you are talking about. Where did
you get it from?

Btw are you sure it is C++ and not C#? DllImport is
not going to work in VC++. Use comment pragma instead:

#pragma comment( lib, "libname.lib" )

Note it is not a .DLL but a .LIB ...
Post by hs1290
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my project.bib
files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid() with a
prototype from hid.dll, along with necessary header files.
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced in
How can I add a reference to hid.dll to make this error go away? I tried
'DllImport' : attribute not found.
hs1290
2007-07-25 13:53:52 UTC
Permalink
Many thanks for your comments.

Yes -- I am trying to move from big brother desktop to CE, but also from VB
to VC++ for management of IO functions.
I couldn't find hid.dll anywhere in WinCE (only usbhid.dll) so I took
hid.dll from the Windows DDK! I then added it to my .BIB file.

I tried the pragma that you suggested (I am definitely using C++ here), but
it didn't clear my problem either, so I have changed my code to use
LoadLibrary/GetProcAddress, which allows me to compile .... but then
LoadLibrary("hid.dll") fails when run on my device, even though hid.dll is
there.

I also tried LoadLibrary("usbhid.dll") on the device -- that fails too.
LoadLibrary fails for most of the DLLs in the \Windows folder on my
device -- but there are a few DLLs for which it succeeds. I have tried to
use the RegEdit to figure out what makes the difference, but without success
so far!

Any further suggestions would be much appreciated.
Thanks.
Post by voidcoder
You are confusing it with big brother windows desktop
I'm afraid. There is nothing like this on CE. Also not
clear what "hid.dll" you are talking about. Where did
you get it from?
Btw are you sure it is C++ and not C#? DllImport is
#pragma comment( lib, "libname.lib" )
Note it is not a .DLL but a .LIB ...
Post by hs1290
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my project.bib
files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid() with
a prototype from hid.dll, along with necessary header files.
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced in
How can I add a reference to hid.dll to make this error go away? I tried
'DllImport' : attribute not found.
voidcoder
2007-07-25 14:12:30 UTC
Permalink
Nope, you can't run any windows desktop code (eg. hid.dll)
on windows ce. It is not compatible at all!

Also don't try to use usbhid.dll instead of hid.dll. First
it is USB Host Client driver (vs. ordinary DLL) and is not
exposing any API for use from user applications. Second
usbhid.dll is not an analogue or replacement for desktop
hid.dll. It is totally different thing. You will need to
find a different way to accomplish your task on ce ...


- Oleg
Post by hs1290
Many thanks for your comments.
Yes -- I am trying to move from big brother desktop to CE, but also from VB
to VC++ for management of IO functions.
I couldn't find hid.dll anywhere in WinCE (only usbhid.dll) so I took
hid.dll from the Windows DDK! I then added it to my .BIB file.
I tried the pragma that you suggested (I am definitely using C++ here), but
it didn't clear my problem either, so I have changed my code to use
LoadLibrary/GetProcAddress, which allows me to compile .... but then
LoadLibrary("hid.dll") fails when run on my device, even though hid.dll is
there.
I also tried LoadLibrary("usbhid.dll") on the device -- that fails too.
LoadLibrary fails for most of the DLLs in the \Windows folder on my
device -- but there are a few DLLs for which it succeeds. I have tried to
use the RegEdit to figure out what makes the difference, but without success
so far!
Any further suggestions would be much appreciated.
Thanks.
Post by voidcoder
You are confusing it with big brother windows desktop
I'm afraid. There is nothing like this on CE. Also not
clear what "hid.dll" you are talking about. Where did
you get it from?
Btw are you sure it is C++ and not C#? DllImport is
#pragma comment( lib, "libname.lib" )
Note it is not a .DLL but a .LIB ...
Post by hs1290
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my project.bib
files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid() with
a prototype from hid.dll, along with necessary header files.
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced in
How can I add a reference to hid.dll to make this error go away? I tried
'DllImport' : attribute not found.
hs1290
2007-07-25 18:41:57 UTC
Permalink
Thanks.
It's unfortunate that the sample code that ships with Windows CE 6.0 (such
as C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USB\CLASS\HID) does not come
anywhere close to successful compiling and linking, and has no accompanying
documentation at all.

For example, the HIDCLASS\MDD sample calls LoadDriver(), which can be
replaced by LoadLibrary() to force compilation, and then cannot resolve
references to:
_HidPdd_GetReport
_HidPdd_SetReport
_HidPdd_GetString
_HidPdd_IssueCommand
_HidPdd_SetIdl
_HidP_FreeCollectionDescription
_HidP_GetCollectionDescription
_HidP_SysPowerEvent
Post by voidcoder
Nope, you can't run any windows desktop code (eg. hid.dll)
on windows ce. It is not compatible at all!
Also don't try to use usbhid.dll instead of hid.dll. First
it is USB Host Client driver (vs. ordinary DLL) and is not
exposing any API for use from user applications. Second
usbhid.dll is not an analogue or replacement for desktop
hid.dll. It is totally different thing. You will need to
find a different way to accomplish your task on ce ...
- Oleg
Post by hs1290
Many thanks for your comments.
Yes -- I am trying to move from big brother desktop to CE, but also from
VB to VC++ for management of IO functions.
I couldn't find hid.dll anywhere in WinCE (only usbhid.dll) so I took
hid.dll from the Windows DDK! I then added it to my .BIB file.
I tried the pragma that you suggested (I am definitely using C++ here),
but it didn't clear my problem either, so I have changed my code to use
LoadLibrary/GetProcAddress, which allows me to compile .... but then
LoadLibrary("hid.dll") fails when run on my device, even though hid.dll
is there.
I also tried LoadLibrary("usbhid.dll") on the device -- that fails too.
LoadLibrary fails for most of the DLLs in the \Windows folder on my
device -- but there are a few DLLs for which it succeeds. I have tried
to use the RegEdit to figure out what makes the difference, but without
success so far!
Any further suggestions would be much appreciated.
Thanks.
Post by voidcoder
You are confusing it with big brother windows desktop
I'm afraid. There is nothing like this on CE. Also not
clear what "hid.dll" you are talking about. Where did
you get it from?
Btw are you sure it is C++ and not C#? DllImport is
#pragma comment( lib, "libname.lib" )
Note it is not a .DLL but a .LIB ...
Post by hs1290
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my
project.bib files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid()
with a prototype from hid.dll, along with necessary header files.
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced
How can I add a reference to hid.dll to make this error go away? I
error C2337: 'DllImport' : attribute not found.
dbgrick
2007-07-25 13:54:03 UTC
Permalink
Try using LoadLibrary and then GetProcAddress to retrieve the functional
pointer. Then you can just call the method using the functional pointer:

HINSTANCE hHIDLib;
// THis has to match your functional definition. This is only an example
DWORD (*pGetHID) (void);

hHIDLib = LoadLibrary (TEXT("hid.dll"));
if (hHIDLib != NULL)
{
pGetHID = (DWORD (*) (void))GetProcAddress((HMODULE)hHIDLib,
TEXT("GetHID"));
}


Rick D.
Contractor
Post by hs1290
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my project.bib
files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid() with a
prototype from hid.dll, along with necessary header files.
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced in
How can I add a reference to hid.dll to make this error go away? I tried
'DllImport' : attribute not found.
hs1290
2007-07-25 14:03:28 UTC
Permalink
Thanks Rick,
I have tried this and it compiles OK -- as per my last posting.
But, on my device, LoadLibrary("hid.dll") fails -- returning a null pointer.
Post by dbgrick
Try using LoadLibrary and then GetProcAddress to retrieve the functional
HINSTANCE hHIDLib;
// THis has to match your functional definition. This is only an example
DWORD (*pGetHID) (void);
hHIDLib = LoadLibrary (TEXT("hid.dll"));
if (hHIDLib != NULL)
{
pGetHID = (DWORD (*) (void))GetProcAddress((HMODULE)hHIDLib,
TEXT("GetHID"));
}
Rick D.
Contractor
Post by hs1290
I want to access a USB-HID device from Windows CE.
I added USB support from the catalog and added hid.dll to my project.bib
files section before building my SDK.
I created a basic VC++ project and added a call to HidD_GetHidGuid() with a
prototype from hid.dll, along with necessary header files.
error LNK2019: unresolved external symbol _HidD_GetHidGuid referenced in
How can I add a reference to hid.dll to make this error go away? I tried
'DllImport' : attribute not found.
Continue reading on narkive:
Loading...