caution: version match problem. if the target is 32bit we need to modify
cygwincompiler.py in /your_py_path/lib/disutils/cygwincompiler.py
find class Mingw32CCompiler and its __init__
we have:
self.set_executables(compiler='gcc -m32 -O -Wall',
compiler_so='gcc -m32 -mdll -O -Wall',
compiler_cxx='g++ -m32 -O -Wall',
linker_exe='gcc -m32',
linker_so='%s %s %s'
% (self.linker_dll, shared_option,
entry_point))
make sure "-m32" is contained in any string with gcc or g++.
don't forget self.linker_dll.
now in psycopg2 directory:
type:
python setup.py build_ext -c mingw32 --pg-config /d/pgsql/bin/pg_config.exe build
it just works.