Elektroda.pl
Elektroda.pl
X
Proszę, dodaj wyjątek www.elektroda.pl do Adblock.
Dzięki temu, że oglądasz reklamy, wspierasz portal i użytkowników.

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

KowalD 24 Lis 2008 20:05 3120 4
  • #1 24 Lis 2008 20:05
    KowalD
    Poziom 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;)??

    0 4
  • #2 24 Lis 2008 22:57
    Akane
    Poziom 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".

    0
  • #3 24 Lis 2008 23:56
    KowalD
    Poziom 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

    0
  • Pomocny post
    #4 25 Lis 2008 00:01
    Akane
    Poziom 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.

    0
  • #5 25 Lis 2008 00:16
    KowalD
    Poziom 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 :/...

    0