Elektroda.pl
Elektroda.pl
X

Search our partners

Find the latest content on electronic components. Datasheets.com
Please add exception to AdBlock for elektroda.pl.
If you watch the ads, you support portal and users.

[visual c++] usb + ddk + hid + biblioteki

KowalD 24 Nov 2008 20:05 3255 4
  • #1
    KowalD
    Level 17  
    probuje napisac program, ktory bedzie wykrywal podlaczenie urzadzenia HID do portu usb... sciagnalem ddk... do pliku dodalem naglawek <hidsdi.h>, dodalem sciezki do folderow zawierajacych naglowki i biblioteki w ddk:
    Code:
    Tools -> Options->
    
    Projects and Solutions -> VC++ Directories
    ->Executable Files
    x:\WINDDK\3790.1830\bin            
    ->Include Files
    x:\WINDDK\3790.1830\inc\wxp
    ->Library Files
    x:\WINDDK\3790.1830\lib\wxp\i386

    plik sie kompiluje bez problemu, jednak gdy chce zbudowac projekt to mam problem:
    Code:
    Linking...
    
    usb.obj : error LNK2019: unresolved external symbol "unsigned char __stdcall HidD_GetAttributes(void *,struct _HIDD_ATTRIBUTES *)" (?HidD_GetAttributes@@YGEPAXPAU_HIDD_ATTRIBUTES@@@Z) referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailW@24 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetClassDevsW@16 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol "void __stdcall HidD_GetHidGuid(struct _GUID *)" (?HidD_GetHidGuid@@YGXPAU_GUID@@@Z) referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)

    oczywiscie w opcjach projektu: Linker->Input->additional dependencies dodalem hid.lib...

    gdzie moglem cos ominac/przegapic/popsuc;)??
  • #2
    Akane
    Level 27  
    Główny (widoczny) błąd polega na tym iż skompilowałeś swój kod jako cpp zamiast C.
    Tip: zapisz plik jako usb.c i dodaj go do projektu, a .cpp usuń. Lub ewentualnie #include <hidsdi.h> ujmij w extern "C".
  • #3
    KowalD
    Level 17  
    kurcze, nie myslalem, ze to moze miac az takie znaczenie... ale i tak sie nie udalo ;(...

    gdy zrobie
    Code:
    extern "C" {
    
    #include <hidsdi.h>
    }

    to bledy z linkowania sa takie:
    Code:
    Linking...
    
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailW@24 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetClassDevsW@16 referenced in function "int __cdecl bOpenHidDevice(void * *,unsigned short,unsigned short)" (?bOpenHidDevice@@YAHPAPAXGG@Z)
    D:\Program Files\Microsoft Visual Studio 9.0\Projects\usb\Debug\usb.exe : fatal error LNK1120: 4 unresolved externals


    a gdy mam plik .c to jest tak:
    Code:
    Linking...
    
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailW@24 referenced in function _bOpenHidDevice
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4 referenced in function _bOpenHidDevice
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 referenced in function _bOpenHidDevice
    usb.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetClassDevsW@16 referenced in function _bOpenHidDevice
    D:\Program Files\Microsoft Visual Studio 9.0\Projects\usb\Debug\usb.exe : fatal error LNK1120: 4 unresolved externals
  • Helpful post
    #4
    Akane
    Level 27  
    Zaznacz SetupDiGetDeviceInterfaceDetail i wciśnij F1. Zaczekaj cierpliwie na nowe okno, przewiń w dół do tabeli Requirements i zerknij co pisze w tabelce obok Library.
  • #5
    KowalD
    Level 17  
    sprawdzilem dla wszystkich fukcji z bledow... nie mam tabelek, a pisza tak: Headers: Declared in setupapi.h. Include setupapi.h., wiec niewiele chyba...

    i takie glupie pytanie... odnosnie katalogow jakie dodaje do "poszukiwania" bibliotek, czyli:
    Code:
    Tools -> Options-> 
    
    Projects and Solutions -> VC++ Directories
    ->Executable Files
    x:\WINDDK\3790.1830\bin             
    ->Include Files
    x:\WINDDK\3790.1830\inc\wxp
    ->Library Files
    x:\WINDDK\3790.1830\lib\wxp\i386
    bo nie wiem, czy to dobrze poustawialem... nie wiem tez, czy to ma znaczenie, ale procesor to amd athlon 64 i do tego windows xp (32bit) sp2...

    EDIT:
    problem rozwiazany... brakowalo jeszcze jednej biblioteki :/...