PCSC-Lite Codes on Windows - 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

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

Related

Question for GCC equation.com for building the using static

I like windows gcc equation.com because it like ran natively just like windows compiler. However :
I will need some dll's that not included on distributed package. if i compiled a windows equation.com gfortran program like using Openblas, it will need libgcc_s_seh-1.dll libgfortran-5.dll libquadmath-0.dll libwinpthread-1.dll.
I could find it on web. But how to make it statically linked, i saw libgcc.a libgfortran.a libquadmath.a libpthread.a so i dont have to copy the dll from other. It is possible ?
For several c source code it need include <sys/resource.h> that not included. It's compatible with resource.h from where. After just copied from others, and recompile.
I got error :
c:\gcc\x86_64-w64-mingw32\include\sys\resource.h:74:29: error: unknown type name 'id_t'; did you mean 'pid_t'?
Is there any forum for this type gcc? Is there any debugger for windows gcc that friendly like VisualStudio Community for Intel Fortran.
Regards.

OpenMP with Clang 5.0 and MinGW

I have trouble making Clang work with MinGW on Windows.
I have MinGW-W64-builds-4.3.3 installed (GCC 7.2.0) as well as the newest Clang/LLVM (by installer on the website).
I am compiling with:
-target x86_64-pc-windows-gnu
option and Clang finds all the headers. Unfortunately there is an error from the linker when I am using OpenMP. It looks like this:
: undefined reference to `__imp___kmpc_fork_call'
\libgomp.a(team.o):(.text+0x19): undefined reference to `pthread_mutex_destroy'
...
When I try to use -fopenmp=libomp flag I am getting errors like this:
...: undefined reference to `__imp___kmpc_fork_call'
...: undefined reference to `__imp___kmpc_for_static_init_4'
...: undefined reference to `__imp___kmpc_for_static_fini'
...: undefined reference to `__imp___kmpc_barrier'
...
It all works without problems when compiling with GCC.
Is there a way to make it (openmp) work without Visual Studio installed? If no, is there some minimilastic Visual Studio installer which just pulls needed libraries/headers and not the whole IDE etc.?
I surely don't know what I am doing here. Explain like I am five answers are very appreciated.
What solved the issue for me was adding libomp.lib to the list of files to compile. This seems to be necessary no matter if I have -static in compiler options and no matter if it's:
-fopenmp=libomp
or
-fopenmp=libiomp5
(as the commenter suggested)
Summing things up, I needed:
clang --target x86_64-pc-windows-gnu -fopenmp=libomp ... C:\FULL\PATH\TO\libomp.lib
To make it work with MinGW-W64-builds-4.3.3 and Clang 5.0.1

Cross compiling FFmpeg + Qt application with MXE

I got a pretty simple project that uses Qt as well as FFmpeg that i developed under linux.
Now I'am having trouble cross compiling said project with MXE to use it on a windows machine.
Under linux everything i had to do was adding
LIBS += -lavcodec -lavformat -lswscale -lavutil
to Qt's .pro file and wrap the includes for FFmpeg in an "extern "C"" block and it compiles just fine.
Now for MXE i just cloned the git repo and used
make MXE_TARGETS='x86_64-w64-mingw32.static' qt5 ffmpeg
As the MXE doc states i set the PATH variable and used
qmake && make
But i get a lot of undefined reference errors regarding libavformat.
Can anybody tell me what i am doing wrong here? I'm kinda lost.
Okay so I got this working.
The mxe version of gcc requires you to include the library multiple times if it is referenced by a library after it in the list of libraries to link.
Add -lavformat to the end of the LIBS line.

Error: multiple definition of `fprint' - while using SDL_ttf

I have a custom library that utilises this code (https://www.dropbox.com/s/iwft7snjmntf160/SoASpriteFont.zip?dl=0).
The linked code was written for Visual Studio; I am using CodeLite on Windows.
Its has a SpriteFont.cpp that uses fprintf.
The static library that has SpriteFont as part of it compiles fine on its own and produces a *.a quite happily.
However when I use SpriteFont via other code, I get a linker error (if I am not mistaken):
D:/Coding/TDM-GCC-32/bin/g++.exe -o ./Debug/tmp #"tmp.txt" -L. -L../deps/lib/ -L../bengine/lib/ -lbengine -lSDL2_ttf -lSDL2main -lSDL2 -lopengl32 -lglew32
D:/Coding/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../libmsvcrt.a(dsnos00619.o):(.text+0x0): multiple definition of `fprintf'
../bengine/lib//libbengine.a(SpriteFont.cpp.o):D:/Coding/TDM-GCC-32/include/stdio.h:243: first defined here
I have read all over and found some similar situations but nothing that I have managed to use to resolve this.
It sounds like there is an issue with the way TDM-GCC redefines fprint in its' stdio.h, but I can't see how. Upon further examination, I believe the problem may lie with SDL_ttf, which is used by SpriteFont.
Also, I have tried using other functions from stdio.h and they compile fine; problem only seems to be fprintf
I have tried to create a barebones program to illustrate the problem. Hope it helps. Hopefully the fact it is a CodeLite project won't be a source of irritation.
If I can provide more info or code please ask.
This usually happens in MinGW when linking against a dll file that also has file in the form of <NAME>.dll.a
To fix this, just link against the dll directly (I recently encountered the same problem when build LLDB debugger on Windows /w MinGW, the solution was to link directly against the dll file and delete the dll.a file

Errors while migrating Qt project from Linux to Windows

I have a Qt project develop on linux, but now I need to compile on windows. I'm having a couple of problems in the migration process.
The first error I'm getting it's:
C:\Qt\Qt5.5.1\Tools\mingw492_32\i686-w64-mingw32\include\c++\bits\c++0x_warning.h:32: error:
#error This file requires compiler and library support for the ISO C++ 2011 standard.
This support is currently experimental, and must be enabled with the
-std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
and this it's how I'm putting it in the .pro of my project
QMAKE_CXXFLAGS += -std=c++11
I also try with
CONFIG += c++11
but the problem continuous.
To give a little more of information, I'm using the MinGW compiler that the Qt Creator install and the extension of my Headers and Sources are: .H and .C (Just in case this have anything to do with the problem, because I've seen that Qt always uses .cpp)
What could be the cause of the problem ?? If something it's unclear or more information it's needed please let me know.
I solve the problem, for me it worked when I change the extension of my sources, I change .C for .cc

Resources