Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling pygraphviz: Unrecognized command line option '-mno-cygwin'

On Windows 7, when trying to compile pygraphviz, I run

    python setup.py build -c mingw32

I get

C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-IC:\Program Files (x86)\Graphv iz 2.28\include\graphviz" -Ic:\Python27\include -Ic:\Python27\PC -c pygraphviz/g raphviz_wrap.c -o build\temp.win-amd64-2.7\Release\pygraphviz\graphviz_wrap.o cc1.exe: error: unrecognized command line option '-mno-cygwin' error: command 'gcc' failed with exit status 1

Where is that '-mno-cygwin' coming from? Greping through the pygraphviz-1.1 directory shows no occurences of "no-cygwin".

like image 874
Dan Hook Avatar asked Nov 27 '12 20:11

Dan Hook


2 Answers

See this answer: https://stackoverflow.com/a/6035864/1516291

In short, you may need to modify distutils\cygwinccompiler.py in your python installation dir to remove traces of -mno-cygwin.

like image 82
Wang Tang Avatar answered Nov 18 '22 12:11

Wang Tang


I had the same problem which has been fixed by replacing instances of the string "-mno-cygwin" with "" in the C:\Python27\Lib\distutils\cygwinccompiler.py

i.e. Original code:

    self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
                         compiler_so='gcc -mno-cygwin -mdll -O -Wall',
                         compiler_cxx='g++ -mno-cygwin -O -Wall',
                         linker_exe='gcc -mno-cygwin',
                         linker_so='%s -mno-cygwin %s %s'
                                    % (self.linker_dll, shared_option,
                                       entry_point))

Updated code:

    self.set_executables(compiler='gcc "" -O -Wall',
                         compiler_so='gcc "" -mdll -O -Wall',
                         compiler_cxx='g++ "" -O -Wall',
                         linker_exe='gcc ""',
                         linker_so='%s "" %s %s'
                                    % (self.linker_dll, shared_option,
                                       entry_point))

What version GCC compiler do you use? You will not get this issue if you use GCC 3.4.4 otherwise you need to replace "-mno-cygwin" string with empty quotes as mentioned above especially for GCC 4.3.7.

like image 3
Khokhar Avatar answered Nov 18 '22 11:11

Khokhar