views:

642

answers:

4

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
A: 

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.

martin
I've deleted pcsc_stringify_error but as expected, I still got other errors. I'm not sure how can I implement OpenSC in my project even though it looks similar. Can you please elaborate more on that ?BTW, I tried coding in Visual C++ .Net and I got no errors when I use #include <winscard.h> and I can use SCardEstablishContext without any problems, but I got errors when I use that code in Qt.
aurorius
That is already a question about Qt rather than PC/SC. Can't help you with this, know your tools.
martin
A: 

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..

glenner
update: just found out that rebuilding Qt with msvc is not needed anymore, you can download a prebuild version here: http://qt.nokia.com/downloads/windows-cpp-vs2008.Just install and configure Qt Creator to use this Qt version for your build and you should be fine
glenner
A: 

Hi everybody,

glener, how do you configure QTCreator for using MSVC++ instead of minGW. I've changed QT version and it's still using minGW.

THXS!

Txebi
A: 

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.

aurorius