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 refere开发者_Python百科nce 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
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.
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.
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..
精彩评论