Windows 上的 PCSC-Lite 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1777713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PCSC-Lite Codes on Windows
提问by Amree
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:
我已经成功构建了一个可以在 Linux 上使用 Qt 读取 Mifare 1K 卡的程序。所以现在,我希望它在 Windows 上运行。据我所知,Windows 上没有 PCSC-Lite 端口,我需要使用 Windows SDK 中的 winscard。我已经下载了它,并且在 Windows(使用 MingW)中的 Qt 中出现了很多未定义的参考错误。例如:
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
采纳答案by Amree
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
已经有一段时间了,我已经设法使用我的读者附带的示例中的标题解决了这个问题。我的 .pro 文件看起来像这样
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.
我不确定这个解决方案是否可以用于其他类型的阅读器,但它确实解决了我的问题。
回答by Martin Paljak
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
从理论上讲,pcsc-lite 是 Windows PC/SC 堆栈到 UNIX 机器的端口。Windows PC/SC 实现是 pcsc-lite 模仿的“参考实现”。并非所有的 Windows SCard 功能都在 pcsc-lite 中实现,甚至有细微的差异,记录在pcsc-lite 文档中
Don't know about the Qt specifics, but some notes:
不知道 Qt 的具体细节,但有一些注意事项:
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.hfrom OpenSC might be of interest to you as well.
pcsc_stringify_error
是 pcsc-lite 特定的功能。它在 Windows 中不存在- Windows 或 mingw 上没有 pcsclite 库,因此您可能需要不同的 Windows 构建文件。
- 看看 OpenSC 以及它如何使用 PC/SC(-lite),如果您正在使用 mingw 进行构建,请查看“构建”项目。您可能也对 OpenSC 的internal-winscard.h感兴趣。
Except for the pcsc_stringify_error
, your problems are with generic Windows linking and Qt (qmake?) build system.
除了pcsc_stringify_error
,您的问题与通用 Windows 链接和 Qt (qmake?) 构建系统有关。
回答by Amree
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).
我遇到了同样的问题,无法将 Windows SDK 中的 winscard 与 minGW 编译器一起使用。一个快速的解决方法是使用 MSVC++ 编译器(如果你可以访问它的话......)而不是 minGW(你还需要使用 MSVC++ 编译器构建 Qt 本身)。
Probably its also possible to get this working with minGW but i didn't look into it any further..
可能它也可以与 minGW 一起使用,但我没有进一步研究它。