Skip to content

Instantly share code, notes, and snippets.

@Zephor5
Last active July 1, 2023 19:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Zephor5/aea563808d80f488310869b69661f330 to your computer and use it in GitHub Desktop.
Save Zephor5/aea563808d80f488310869b69661f330 to your computer and use it in GitHub Desktop.
  1. install zbar on windows with include and library files

  2. make sure mingw installed and bin directory added to the path

  3. in PYTHONPATH\Lib\distutils, create a file distutils.cfg and add two lines:

    [build]

    compiler=mingw32

  4. get dll lib and include file from ftp://sourceware.org/pub/pthreads-win32/dll-latest copy files to PATH_MINGW32/[lib,bin,include] separately, just need file name like pthreadGC2 and remember to chang the name to libpthread

  5. change or add lines in setup.py:

    extra_compile_args=['-std=c99', '-IPATH_TO\ZBar\include', '-lPATH_TO\ZBar\lib'],

    extra_link_args=["PATH_TO\ZBar\lib\libzbar.dll.a"],

    remove line libraries=['zbar'],

  6. run python setup.py install

@serg123e
Copy link

serg123e commented Jan 9, 2017

please note that you have to use doubled backslashes in step 5:
extra_compile_args=['-std=c99', '-IPATH_TO\ZBar\include', '-lPATH_TO\ZBar\lib'],
extra_link_args=["PATH_TO\ZBar\lib\libzbar.dll.a"],

@Zephor5
Copy link
Author

Zephor5 commented Jan 25, 2017

For insurance purposes, yes. normally it's ok. @serg123e

@Niedzwiedzw
Copy link

Can you please rewrite those instructions? It's ununderstandable...

@dannye
Copy link

dannye commented Mar 25, 2017

Yes, I am also having trouble understanding the instructions.
Can you re-explain step 4?

@gyb001
Copy link

gyb001 commented Nov 16, 2017

PS E:\py\zbar-0.10> C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\python.exe setup.py install
running install
running build
running build_ext
Traceback (most recent call last):
File "setup.py", line 43, in
extra_link_args=["C:\Program Files (x86)\ZBar\lib\libzbar.dll.a"],
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build_ext.py", line 308, in run
force=self.force)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\ccompiler.py", line 1031, in new_compiler
return klass(None, dry_run, force)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\cygwinccompiler.py", line 282, in init
CygwinCCompiler.init (self, verbose, dry_run, force)
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\cygwinccompiler.py", line 157, in init
self.dll_libraries = get_msvcr()
File "C:\Users\bence.gyarfas\AppData\Local\Programs\Python\Python36-32\lib\distutils\cygwinccompiler.py", line 86, in get_msvcr
raise ValueError("Unknown MS Compiler version %s " % msc_ver)
ValueError: Unknown MS Compiler version 1900

@mattm401
Copy link

mattm401 commented Dec 6, 2017

I am similarly having some issues following/understanding these instructions and get output that looks like this when I try to run the setup file:

C:\zbarlight-1.2>python setup.py install
C:\Python27\Lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'optional'
warnings.warn(msg)
running install
running bdist_egg
running egg_info
writing requirements to src\zbarlight.egg-info\requires.txt
writing src\zbarlight.egg-info\PKG-INFO
writing top-level names to src\zbarlight.egg-info\top_level.txt
writing dependency_links to src\zbarlight.egg-info\dependency_links.txt
reading manifest file 'src\zbarlight.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs'
no previously-included directories found matching 'tests'
warning: no previously-included files matching '.py[cod]' found anywhere in distribution
warning: no previously-included files matching 'pycache' found anywhere in distribution
warning: no previously-included files matching '
.so' found anywhere in distribution
warning: no previously-included files found matching 'Makefile'
warning: no previously-included files found matching 'requirements-dev.txt'
warning: no previously-included files found matching 'tox.ini'
writing manifest file 'src\zbarlight.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
building 'zbarlight._zbarlight' extension
c:\mingw\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c src/zbarlight/_zbarlight.c -o build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o -std=c99 "-IC:\Program Files (x86)\ZBar\include" "-lC:\Program Files (x86)\ZBar\lib"
writing build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.def
c:\mingw\bin\gcc.exe -shared -s build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.def -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -LC:\Python27\PC\VS9.0\amd64 -lpython27 -lmsvcr90 -o build\lib.win-amd64-2.7\zbarlight_zbarlight.pyd "C:\Program Files (x86)\ZBar\lib\libzbar.dll.a"
build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o:_zbarlight.c:(.text+0x1c): undefined reference to _imp__Py_InitModule4' build\temp.win-amd64-2.7\Release\src\zbarlight\_zbarlight.o:_zbarlight.c:(.text+0x7c): undefined reference to _imp__Py_BuildValue'
build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o:_zbarlight.c:(.text+0x8c): undefined reference to _imp__PyModule_AddObject' build\temp.win-amd64-2.7\Release\src\zbarlight\_zbarlight.o:_zbarlight.c:(.text+0xf1): undefined reference to _imp__PyArg_ParseTuple'
build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o:_zbarlight.c:(.text+0x116): undefined reference to _imp__PyString_AsStringAndSize' build\temp.win-amd64-2.7\Release\src\zbarlight\_zbarlight.o:_zbarlight.c:(.text+0x264): undefined reference to _imp___Py_NoneStruct'
build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o:_zbarlight.c:(.text+0x275): undefined reference to _imp__PyList_New' build\temp.win-amd64-2.7\Release\src\zbarlight\_zbarlight.o:_zbarlight.c:(.text+0x290): undefined reference to _imp__PyString_FromString'
build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o:_zbarlight.c:(.text+0x299): undefined reference to _imp__PyList_Append' build\temp.win-amd64-2.7\Release\src\zbarlight\_zbarlight.o:_zbarlight.c:(.text+0x30f): undefined reference to _imp__PyArg_ParseTuple'
build\temp.win-amd64-2.7\Release\src\zbarlight_zbarlight.o:_zbarlight.c:(.text+0x33a): undefined reference to `_imp__Py_BuildValue'
collect2: ld returned 1 exit status
error: command 'c:\mingw\bin\gcc.exe' failed with exit status 1

any thoughts on what the issue might be?

@vanjavk
Copy link

vanjavk commented Dec 22, 2017

wtf do I need to do on step 4?

@jhgalino
Copy link

jhgalino commented Apr 2, 2018

how to step 4?

@PopeSo
Copy link

PopeSo commented Apr 21, 2018

when i following these instructions i have the same problem as @mattm401
error: command 'c:\mingw\bin\gcc.exe' failed with exit status 1
so what should i do for this issue?

@stupid-venky
Copy link

Can someone please clearly say me the steps to install " Zbarlight " in windows . Cause I'm trying it for long time but I can't able to fix it.

@stupid-venky
Copy link

Can some one help me to install zbar light in windows ?

@ruvi-d
Copy link

ruvi-d commented Nov 12, 2020

@ronytesler
Copy link

@ruvi-d I created a whl file, then ran pip install zbarlight-3.1.dev0-cp38-cp38-win_amd64.whl, but when I add import zbarlight I get an error - ImportError: DLL load failed while importing _zbarlight: The specified module could not be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment