smihica / pyminizip

To create a password encrypted zip file in python.
Other
106 stars 37 forks source link

Building error : type error z_crc_t unknown #18

Closed Lexsek closed 6 years ago

Lexsek commented 6 years ago

Hello, On ArchLinux, my pip install pyminizip and setup.py build are ending with the same error :

In file included from /usr/include/python3.6m/Python.h:39:0, from src/py_minizip.c:17: src/crypt.h:35:53: error: nom de type « z_crc_t » inconnu static int decrypt_byte(unsigned long pkeys, const z_crc_t pcrc_32_tab) ^~~ src/crypt.h:48:52: error: nom de type « z_crc_t » inconnu static int update_keys(unsigned long pkeys, const z_crc_t pcrc_32_tab,int c) ^~~ src/crypt.h:65:71: error: nom de type « z_crc_t » inconnu static void init_keys(const char passwd, unsigned long pkeys, const z_crc_t* pcrc_32_tab)

Full output below :

running build running build_ext building 'pyminizip' extension gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fPIC -Isrc -Izlib123 -I/usr/include/python3.6m -c src/py_minizip.c -o build/temp.linux-x86_64-3.6/src/py_minizip.o In file included from /usr/include/python3.6m/Python.h:39:0, from src/py_minizip.c:17: src/crypt.h:35:53: error: nom de type « z_crc_t » inconnu static int decrypt_byte(unsigned long pkeys, const z_crc_t pcrc_32_tab) ^~~ src/crypt.h:48:52: error: nom de type « z_crc_t » inconnu static int update_keys(unsigned long pkeys, const z_crc_t pcrc_32_tab,int c) ^~~ src/crypt.h:65:71: error: nom de type « z_crc_t » inconnu static void init_keys(const char passwd, unsigned long pkeys, const z_crc_t pcrc_32_tab) ^~~ src/py_minizip.c: Dans la fonction « py_compress_multiple »: src/py_minizip.c:446:14: warning: déclaration implicite de la fonction « PyString_Check »; vouliez-vous utiliser « PyMapping_Check » ? [-Wimplicit-function-declaration] if (!PyString_Check(str_obj) && !PyUnicode_Check(str_obj)) { ^~~~~~ PyMapping_Check src/py_minizip.c:459:19: warning: déclaration implicite de la fonction « PyString_AsString »; vouliez-vous utiliser « PyBytes_AsString » ? [-Wimplicit-function-declaration] srcs[i] = PyString_AsString(str_obj); ^~~~~ PyBytes_AsString src/py_minizip.c:459:17: warning: l'affectation transforme un entier en pointeur sans transtypage [-Wint-conversion] srcs[i] = PyString_AsString(str_obj); ^ In file included from /usr/include/python3.6m/Python.h:39:0, from src/py_minizip.c:17: Au plus haut niveau: src/crypt.h:65:13: warning: « init_keys » défini mais pas utilisé [-Wunused-function] static void init_keys(const char passwd, unsigned long pkeys, const z_crc_t pcrc_32_tab) ^~~~~ src/crypt.h:35:12: warning: « decrypt_byte » défini mais pas utilisé [-Wunused-function] static int decrypt_byte(unsigned long pkeys, const z_crc_t pcrc_32_tab) ^~~~ error: command 'gcc' failed with exit status 1

Lexsek commented 6 years ago

I managed to build and install it by adding "typedef unsigned long z_crc_t;" to crypt.h in src folder. But now I've got a problem when I try to import pyminizip using python3 Using python2 works

Python 3.6.5 (default, Apr 14 2018, 13:17:30) [GCC 7.3.1 20180406] on linux Type "help", "copyright", "credits" or "license" for more information.

import pyminizip Traceback (most recent call last): File "", line 1, in ImportError: /usr/lib/python3.6/site-packages/pyminizip-0.2.1-py3.6-linux-x86_64.egg/pyminizip.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PyString_Check

veon82 commented 6 years ago

The typedef fix is good for the z_crc_t type error, I introduced the same fix (along with other features) in a PR that I just submitted. The error you get when building with Python3 is another issue, PyString_Check symbol is not used anymore on Python3 Dev library, the code should be reviewed to get this module working with Py3.

veon82 commented 6 years ago

I've patched #19 with a fix to get Python3 working, let's wait for a feedback from @smihica. Meanwhile would you try it and check if it fixes your problem when importing pyminizip module on Python3? Thanks

Lexsek commented 6 years ago

Sorry for the late answer. It works perfectly under python3 after your fix ! Thank you !

Meow-ops commented 6 years ago

My fix was to include #include in the same file instead of directly a typedef