I have been having a terrible time trying to compile a python extension - hopefully someone can help.
I initially tried executing 'python.exe setup.py build' but received the error: 'Python was built Visual Studio 2003; extensions must be built with a compiler that can generate compatible binaries...".
So I then downloaded Cygwin, and have tried sending the switch '-c mingw32'. A few lines were written into the console - then I get the error message: command 'gcc' failed: Permission denied.
I was initially using the Visual Studio 2010 Command Line to do this, but tried with bash and got the same result.
I have spent a considerable amount of time researching the issue, and it appears Cygwin uses symlinks for gcc and g++, and windows doesn't understand how to handle this.
How exactly can I force setup.py to use gcc-3.exe instead of the gcc.exe symlink?
I know it's inelegant, but you can rename the symlink and copy gcc-3.exe to gcc.exe. That worked for me when I used Cygwin's gcc. You might want to switch to the mingw64-i686 (or mingw64-x86_64) package to get gcc 4.5.3, or just install MinGW-w64 separately for compiling under Windows.
Also, you can permanently configure distuilts in PythonXX\Lib\distutils\distutils.cfg:
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
[build_clib]
compiler = mingw32
Related
I have python code that I am using Cython to convert to C (in order to call from C# 32bit application).
When I use MSVC x86 Native Tool Command prompt to run:
python setup.py build_ext --inplace --compiler=msvc
I get the error:
python38.lib(python38.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX86\x86\link.exe' failed with exit status 1112
When I use MSVC X64 Native Tool command prompt, I try to first run: setenv /x86 but setenv is not recognized. However, I can build as x64 successfully. When I compile the resulting c code as dll to call from C#, it is not a surprise that I get the following memory access violation:
System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory.
This is often an indication that other memory is corrupt.
I was wondering how to solve this issue, and be able to build for x86.
Thanks very much in advance!
I tried all the options to make mingw32 compiler work, but every time I get this error
CompileError: command 'c:\\\\mingw\\\\bin\\\\gcc.exe' failed with exit status 1\n
and don't know how to fix it.
Steps that I have done:
Installed Anaconda 2.7 win 32 bits (Although my computer is 64 bits, but since the python is working I assume it should not be a problem)
Installed Microsoft Visual C++ Compiler for Python 2.7
Installed mingw32 and added to system environment path (I tested at command prompt by calling gcc and it is working)
Created distutils.cfg in C:\Python27\Lib\distutils folder
I appreciate if someone could help me on this.
From all that I've read, I get the impression that building from source (relatively speaking) is pretty easy within Cygwin. However, when I installed the base package along with gcc and attempted to build Python 2.7.8 from source, I got the following error from running ./configure:
checking whether we are cross compiling... configure: error: in `/cygdrive/h/Python-2.7.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Upon opening config.log, I see this:
configure:3978: checking whether we are cross compiling
configure:3986: gcc -o conftest.exe conftest.c >&5
configure:3990: $? = 0
configure:3997: ./conftest.exe
./configure: line 3999: ./conftest.exe: Permission denied
configure:4001: $? = 126
configure:4008: error: in `/cygdrive/h/Python-2.7.8':
configure:4010: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
I'm not sure I understand exactly what the issue is. It appears to attempt to compile conftest.c into conftest.exe (which appears to work?) and subsequently attempts to run the executable but gets denied on the basis of permission.
Any thoughts or insights on where to go from here?
Turns out I had inadvertantly installed the wrong GCC package. Rolling back all of the the development package installs and just installing GNU GCC 4.8.3 resolved the above.
I'd like to use graph-tool on windows 7, but I'm having trouble installing it.
All the requirements listed here are successfully installed. Python 2.7 is installed in C:\python27. Boost 1.49.0 was successfully compiled with mingw, installed in C:\boost and the BOOST_ROOT environment variable is pointing to it. Boost is compiled in debug and release mode and both static and dynamic.
Invoking configure from within MSyS leads to the following error.
configure: error:
Could not link test program to Python. Maybe the main Python library has been
installed in some non-standard library path. If so, pass it to configure,
via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
Calling configure LDFLAGS="-LC:/python27/libs" fixed this error, but lead to the following error
checking for boostlib >= 1.38.0... configure: error: We could not detect the boo
st libraries (version 1.38 or higher). If you have a staged boost library (still
not installed) please specify $BOOST_ROOT in your environment and do not give a
PATH to --with-boost option. If you are sure you have boost installed, then ch
eck your version number looking in <boost/version.hpp>. See http://randspringer.
de/boost for more documentation.
This is weird, since BOOST_ROOT is clearly defined (checked it with printenv command).
The next command I tried was configure --with-boost="C:/boost" LDFLAGS="-LC:/python27/libs"
checking for boostlib >= 1.38.0... yes
checking whether the Boost::Python library is available... no
configure: error: No usable boost::python found
Alright it detects boost, but It can't find boost::python. Due to its size I'm unable to post the config.log on stackoverflow but you can find it here.
I'm really confused right now and would appreciate any help.
I have zero experience with compiling graph-tool (or anything else) for windows, but the following part of your config.log stands out:
configure:17224: checking whether the Boost::Python library is available
configure:17254: g++ -c -Wall -ftemplate-depth-150 -Wno-deprecated -Wno-unknown-pragmas -O99 -fvisibility=default -fvisibility-inlines-hidden -Wno-unknown-pragmas -Ic:\python27\include conftest.cpp >&5
conftest.cpp:32:36: fatal error: boost/python/module.hpp: No such file or directory
compilation terminated.
Note how the boost path you passed is not being used! Try to pass CXXFLAGS="-IC:\boost\include" to configure as well.
May be something like this would help:
./configure --prefix=/usr/
for windows path is different, try it yourself.
Um, I'm stumped and really stuck (+_+) here after googling many sites. I'm using mingw32-gcc.exe from Dev-c++ compiler and currently following instructions from this site.
Every time I try here's the result:
C:\Python26>python c:\python26\python-mcrypt-1.1\setup.py install
running install
running build
running build_ext
error: don't know how to compile C/C++ code on platform 'nt' with 'mingw32-gcc.exe' compiler
I've edited the distuils.cfg file in my c:\python26\lib\distuils\distuils.cfg with this parameter
[build]
compiler = mingw32-gcc.exe
Any ideas would be appreciated!
You installed python outside of a compilation environment valids one include cygwin or mingw32 (wich is used by Dev-C++).
To use the command-line mode, you need to find the your compiler installation and find bat script which launch the shell with the proper parameters (This is needed for bith cygwin and mingw).
The alternative is to use Microsft solution for that problem.