kaoh / globalplatform

C library + command-line for Open- / GlobalPlatform smart cards
https://kaoh.github.io/globalplatform/
Other
72 stars 30 forks source link

Update zlib to 1.3 #61

Open micwoj92 opened 2 years ago

micwoj92 commented 2 years ago

On Linux it builds fine using this version, there were quite a few fixes https://www.zlib.net/ChangeLog.txt

kaoh commented 2 years ago

You mean updating the pre-built and bundled Windows version?

micwoj92 commented 2 years ago

Yes

kaoh commented 2 years ago

You can give it a try in the branch: https://github.com/kaoh/globalplatform/tree/zlib1212

micwoj92 commented 2 years ago

I will need to setup windows enviroment and test a bit on weekend. Just to be sure.

micwoj92 commented 2 years ago

Linking fails for me

[ 81%] Linking C shared library globalplatform.dll
LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx86\x86\link.exe /nologo @CMakeFiles\globalplatform.dir\objects1.rsp /out:globalplatform.dll /implib:globalplatform.lib /pdb:C:\Users\John\Desktop\globalplatform\globalplatform\src\globalplatform.pdb /dll /version:0.0 /machine:X86 /INCREMENTAL:NO globalplatformStatic.lib C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86\winscard.lib C:\Program Files (x86)\OpenSSL-Win32\lib\VC\libssl32MD.lib C:\Program Files (x86)\OpenSSL-Win32\lib\VC\libcrypto32MD.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:globalplatform.dll.manifest" failed (exit code 1120) with the following output:
   Creating library globalplatform.lib and object globalplatform.exp
unzip.c.obj : error LNK2019: unresolved external symbol _inflate@8 referenced in function _unzReadCurrentFile@12
unzip.c.obj : error LNK2019: unresolved external symbol _inflateEnd@4 referenced in function _unzCloseCurrentFile@4
unzip.c.obj : error LNK2019: unresolved external symbol _crc32@12 referenced in function _unzReadCurrentFile@12
unzip.c.obj : error LNK2019: unresolved external symbol _inflateInit2_@16 referenced in function _unzOpenCurrentFile3@20
unzip.c.obj : error LNK2019: unresolved external symbol _get_crc_table@0 referenced in function _unzOpenCurrentFile3@20
globalplatform.dll : fatal error LNK1120: 5 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
koh-osug commented 2 years ago

Sounds familiar when not using a version with proper cdecl calling convention.

Have you use the bundled version like mentioned in the README (adjust the path):

cmake -G "NMake Makefiles" -DZLIB_ROOT="C:\Users\john\Desktop\globalplatform\zlib-1.2.12\win32-build"

Also clean the CMake files before with cleanCMake.sh. Execute it in Cygwin or a git bash environment.

micwoj92 commented 2 years ago

I was using the bundled one, with command cmake -G "NMake Makefiles" -DZLIB_ROOT="C:\Users\John\Desktop\globalplatform\zlib-1.2.12\win32-build" -DCMOCKA_ROOT="C:\Users\John\Desktop\globalplatform\cmocka-cmocka-1.1.5\build-w32" from readme

it didnt work for me first, was complaining about missing zlib.h, so I moved both files from globalplatform\zlib-1.2.12\win32-buildto globalplatform\globalplatform\src\unzip could this be cause of issue?

koh-osug commented 2 years ago

Clean your cmake environment or use a clean checkout to sort our any errors resulting from cached settings from CMake if not already done. CMake has issues when the toolchain is changed and does not reevaluate new paths and settings. Not finding the header file could be related to an old cached setting which's path does not exist anymore.

micwoj92 commented 2 years ago

It's weird, I did delete files and redownloaded, here's output of all commands

C:\Users\John\Desktop\globalplatform>cmake -G "NMake Makefiles" -DZLIB_ROOT="C:\Users\john\Desktop\globalplatform\zlib-1.2.12\win32-build" -DCMOCKA_ROOT="C:\Users\john\Desktop\globalplatform\cmocka-cmocka-1.1.5\build-w32"
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.

-- The C compiler identification is MSVC 19.31.31107.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx86/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Doxygen: C:/Program Files/doxygen/bin/doxygen.exe (found version "1.9.3 (c0b9eafbfb53286ce31e75e2b6c976ee4d345473)") found components: doxygen dot
-- Found DOXYFILE_IN: C:/Users/John/Desktop/globalplatform/globalplatform/Doxyfile.in
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Found PCSC: C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x86/winscard.lib
-- Found OpenSSL: optimized;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/libcrypto32MD.lib;debug;C:/Program Files (x86)/OpenSSL-Win32/lib/VC/libcrypto32MDd.lib (found version "3.0.2")
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.12")
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Found GLOBALPLATFORM: C:/Users/John/Desktop/globalplatform/globalplatform/src/globalplatform.lib
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMOCKA_ROOT

-- Build files have been written to: C:/Users/John/Desktop/globalplatform

C:\Users\John\Desktop\globalplatform>nmake

Microsoft (R) Program Maintenance Utility Version 14.31.31107.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target globalplatformStatic
[  2%] Building C object globalplatform/src/CMakeFiles/globalplatformStatic.dir/connection.c.obj
connection.c
[  5%] Building C object globalplatform/src/CMakeFiles/globalplatformStatic.dir/stringify.c.obj
stringify.c
[  8%] Building C object globalplatform/src/CMakeFiles/globalplatformStatic.dir/crypto.c.obj
crypto.c
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(132): warning C4244: '=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(508): warning C4018: '<': signed/unsigned mismatch
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(871): warning C4018: '<': signed/unsigned mismatch
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(933): warning C4018: '<': signed/unsigned mismatch
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(995): warning C4018: '<': signed/unsigned mismatch
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1053): warning C4018: '<': signed/unsigned mismatch
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1187): warning C4018: '<': signed/unsigned mismatch
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1428): warning C4244: '=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1429): warning C4244: '=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1433): warning C4244: '=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1629): warning C4244: '+=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1700): warning C4244: '+=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(1845): warning C4244: '=': conversion from 'DWORD' to 'BYTE', possible loss of data
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(2030): warning C4101: 'i': unreferenced local variable
C:\Users\John\Desktop\globalplatform\globalplatform\src\crypto.c(2204): warning C4018: '<': signed/unsigned mismatch
[ 10%] Building C object globalplatform/src/CMakeFiles/globalplatformStatic.dir/loadfile.c.obj
loadfile.c
C:\Users\John\Desktop\globalplatform\globalplatform\src\unzip/zip.h(54): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

C:\Users\John\Desktop\globalplatform>
koh-osug commented 2 years ago

Did you really used the command line literally: "C:\Users\john\Desktop\globalplatform\zlib-1.2.12\win32-build". Or have you by accidient the username "john" and cloned the repo also under "Desktop"?

micwoj92 commented 2 years ago

Yes, my windows username is really John (as in john doe) and I also cloned it to desktop

koh-osug commented 2 years ago

No sure if Windows is now case sensitive, maybe "C:\Users\John" instead of "C:\Users\john" is worth a try. But I do not think this is the error reason. I have to check why it works on my end.

micwoj92 commented 2 years ago

Tried and it didn't work, I also tried (with John instead of john) moving files from (as previously) globalplatform\zlib-1.2.12\win32-build to globalplatform\globalplatform\src\unzip and then it also gave that linking issue.

micwoj92 commented 2 years ago

1.2.13 zlib released, I don't have any windows environments atm, but it compiles fine on Linux.

micwoj92 commented 12 months ago

Hello @kaoh, with zlib 1.3 released could you try to check this issue again? I don't have any Windows setup at this time.

koh-osug commented 11 months ago

Yes, this would be worth a try. Quite busy right now, ping me when I forget it.

micwoj92 commented 9 months ago

ping @koh-osug

koh-osug commented 8 months ago

I just searched a binary existing for Windows. It does not seem to exists. I have to compile it manually and have to find a Windows machine.

kaoh commented 8 months ago

Please check the binary The branch is "zlib".