English 中文(简体)
PCSC-Lite Codes on Windows
原标题:

I ve successfully built a program that can read Mifare 1K Card using Qt on Linux. So now, I would like it to run on Windows. From what I ve gathered, there s no PCSC-Lite port on Windows and I need to use winscard from Windows SDK. I ve downloaded it and I got lots of undefined reference errors from my Qt in Windows (with MingW). For example:

release/ReadCard.o:ReadCard.cpp:(.text+0x48e): undefined reference to `pcsc_stringify_error 
release/ReadCard.o:ReadCard.cpp:(.text+0x5e9): undefined reference to `pcsc_stringify_error 
release/ReadCard.o:ReadCard.cpp:(.text+0x7ed): undefined reference to `pcsc_stringify_error 
release/ReadCard.o:ReadCard.cpp:(.text+0x2e56): undefined reference to `SCardListReaderGroups 
release/ReadCard.o:ReadCard.cpp:(.text+0x3adc): undefined reference to `SCardListReaders 
release/ReadCard.o:ReadCard.cpp:(.text+0x3cc6): undefined reference to `SCardListReaders 
release/ReadCard.o:ReadCard.cpp:(.text+0x3f88): undefined reference to `SCardGetStatusChange 
release/ReadCard.o:ReadCard.cpp:(.text+0x4274): undefined reference to `SCardConnect 
release/ReadCard.o:ReadCard.cpp:(.text+0x4d1b): undefined reference to `SCardGetStatusChange

I ve also tried specifying these libraries in the project, but still failed.

LIBS += -lwinscard -lpcsclite WinSCard.Lib
最佳回答

It s been a while and I ve managed to solve this using headers from the example that comes with my reader. My .pro file looks like this


win32 { 
    HEADERS += MainWindow.h 
        ReadCard.h 
        Config.h
    INCLUDEPATH += C:/Omnikey/Include
    LIBS += C:/Omnikey/Lib/winscardn.lib
}
unix { 
    HEADERS += MainWindow.h 
        wintypes.h 
        winscard.h 
        reader.h 
        pcsclite.h 
        ReadCard.h 
        Config.h
    LIBS += -lpcsclite
}

I m not sure if this solution can be used with other type of readers, but it sure solved mine.

问题回答

Theoretically speaking, pcsc-lite is a port of Windows PC/SC stack to UNIX machines. Windows PC/SC implementation is the "reference implementation" which pcsc-lite mimics. Not all Windows SCard functions are implemented in pcsc-lite and there are even minor differences, documented in pcsc-lite documentation

Don t know about the Qt specifics, but some notes:

  • pcsc_stringify_error is a pcsc-lite specific function. It does not exist in Windows
  • there is no pcsclite library on Windows or mingw, so you probably need different build files for Windows.
  • have a look at OpenSC and how it makes use of PC/SC(-lite) and if you re building with mingw, have a look at the "build" project. internal-winscard.h from OpenSC might be of interest to you as well.

Except for the pcsc_stringify_error, your problems are with generic Windows linking and Qt (qmake?) build system.

i ran into the same problem, being unable to use winscard from the Windows SDK together with the minGW compiler. A quick fix is to use the MSVC++ compiler (if you have access to it offcourse..) instead of minGW (you ll need to build Qt itself using the MSVC++ compiler also).

Probably its also possible to get this working with minGW but i didn t look into it any further..





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签