Question

I'm using Python 2.7.3 on Windows XP via the IDLE GUI, and I'm trying to run Z3 4.0 locally via the Python API.

This line works fine:

>>> from z3 import *

This line doesn't:

>>> x = Int('x')

Traceback (most recent call last):
[...]
  File "C:\Program Files\Microsoft Research\Z3-4.0\python\z3core.py", line 34, in init
    _lib = ctypes.CDLL(PATH)
  File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

Anyone know what the problem could be?

My PYTHONPATH is set to "C:\Program Files\Microsoft Research\Z3-4.0\python", without the quotes.

Was it helpful?

Solution

Z3 uses thread local storage. It is implemented using __declspec(thread). Unfortunately, this is not supported by DLLs in Windows XP and Server 2003. From MSN documentation:

"For DLLs that are loaded dymanically after the process has started (delay load, COM objects, explicit LoadLibrary, etc) __declspec(thread) does not work on Windows XP, 2003 Server and earlier OSes, but does work on Vista and 2008 Server."

So, to use the Z3 DLL, you must use one of the following Windows: 8, 7, Vista or Server 2008.

OTHER TIPS

On Windows XP there may be a problem with spaces in file names such that python cannot find z3.dll; this seems to be a general python issue, see, e.g.: some notes on PYTHONPATH

It may work if the old 8.3-format for directories is used. You can find the short names by finding the Z3 directory in a command shell (I use dir /x to see the short names on Windows 7) and on my system the short path is C:\progra~1\mi4430~1\z3-4.0\bin. These numbers are different on every installation though.

A quicker solution may be to simply copy z3.dll from the bin directory to the python directory (or from the x64 directory if you're on 64-bit).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top