Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc compilation error from python

Tags:

python

gcc

cygwin

I know that there are lots of threads on gcc, particularly "command gcc failed with exit status 1", and I've looked at them all and still have not been able to fix this. I only would use gcc or mingw32 for python-related tasks, such as using Cython or other packages that might involve compilation. However, it never seems to work.

I have a PC with Windows 7 Home edition. I've installed cygwin on it with mingw32, and I also have Visual Studio 11 Beta installed, and I'm happy to uninstall/reinstall anything to get this to work.

Cython compilations always fail with

error: command 'gcc' failed with exit status 1

But even trying to install many python packages using pip fails with a similar error. For example, I'm trying to install a package called "xhtml2pdf." After running "pip install xhtml2pdf" in the command prompt, I get the following error:

copying src\reportlab\lib\hyphen.mashed -> build\lib.win32-2.7\reportlab\lib

running build_ext

building '_rl_accel' extension

C:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Pytho
n27\PC -c "C:\Users\JJ\Documents\Coding Fun\build\reportlab\src\rl_addons\rl_acc
el\_rl_accel.c" -o "c:\users\jj\documents\coding fun\build\reportlab\src\rl_addo
ns\rl_accel\_rl_accel.o"

cc1.exe: error: unrecognized command line option '-mno-cygwin'

error: command 'gcc' failed with exit status 1

Running the same command from cygwin yields a different error:

copying src\reportlab\lib\hyphen.mashed -> build\lib.win32-2.7\reportlab\lib

running build_ext

building '_rl_accel' extension

gcc -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c C:\cygwin\home\JJ\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c -o c:\cygwin\home\jj\build\reportlab\src\rl_addons\rl_accel\_rl_accel.o

error: command 'gcc' failed: No such file or directory

----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='C:\\cygwin\\home\\JJ\\build\\reportlab\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record c:\users\jj\appdata\local\temp\pip-aohmse-record\install-record.txt failed with error code 1 in C:\cygwin\home\JJ\build\reportlab
Storing complete log in C:\Users\JJ\AppData\Roaming\pip\pip.log


----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='C:\\Users\\JJ\\Do
cuments\\Coding Fun\\build\\reportlab\\setup.py';exec(compile(open(__file__).rea
d().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-external
ly-managed --record c:\users\jj\appdata\local\temp\pip-r8_mri-record\install-rec
ord.txt failed with error code 1 in C:\Users\JJ\Documents\Coding Fun\build\repor
tlab
Storing complete log in C:\Users\JJ\AppData\Roaming\pip\pip.log

I'm very new to compilation in general, having worked only with interpreted languages, so I've been frustratingly unable to figure out how to fix this myself. Any help would be appreciated in getting this package installed.

EDIT: I have previously followed advice like trying to remove all references to "-mno-cygwin" in distutils and creating a distutils.cfg file, but to no avail.

UPDATE: After reinstalling cygwin and also downgrading my installations of gcc and g++ to v3, I get another, but different, error:

copying src\reportlab\lib\PyFontify.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\pygments2xpre.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\randomtext.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\rltempfile.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\rparsexml.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\sequencer.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\set_ops.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\styles.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\testutils.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\textsplit.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\units.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\utils.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\validators.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\xmllib.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\yaml.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\__init__.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\pdfbase\cidfonts.py -> build\lib.win32-2.7\reportlab\pdfba
se

copying src\reportlab\pdfbase\pdfdoc.py -> build\lib.win32-2.7\reportlab\pdfbase


copying src\reportlab\pdfbase\pdfform.py -> build\lib.win32-2.7\reportlab\pdfbas
e

copying src\reportlab\pdfbase\pdfmetrics.py -> build\lib.win32-2.7\reportlab\pdf
base

copying src\reportlab\pdfbase\pdfpattern.py -> build\lib.win32-2.7\reportlab\pdf
base

copying src\reportlab\pdfbase\pdfutils.py -> build\lib.win32-2.7\reportlab\pdfba
se

copying src\reportlab\pdfbase\rl_codecs.py -> build\lib.win32-2.7\reportlab\pdfb
ase

copying src\reportlab\pdfbase\ttfonts.py -> build\lib.win32-2.7\reportlab\pdfbas
e

copying src\reportlab\pdfbase\_can_cmap_data.py -> build\lib.win32-2.7\reportlab
\pdfbase

copying src\reportlab\pdfbase\_cidfontdata.py -> build\lib.win32-2.7\reportlab\p
dfbase

copying src\reportlab\pdfbase\_fontdata.py -> build\lib.win32-2.7\reportlab\pdfb
ase

copying src\reportlab\pdfbase\_fontdata_enc_macexpert.py -> build\lib.win32-2.7\
reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_macroman.py -> build\lib.win32-2.7\r
eportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_pdfdoc.py -> build\lib.win32-2.7\rep
ortlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_standard.py -> build\lib.win32-2.7\r
eportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_symbol.py -> build\lib.win32-2.7\rep
ortlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_winansi.py -> build\lib.win32-2.7\re
portlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_zapfdingbats.py -> build\lib.win32-2
.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courier.py -> build\lib.win32-2.7
\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courierbold.py -> build\lib.win32
-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courierboldoblique.py -> build\li
b.win32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courieroblique.py -> build\lib.wi
n32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helvetica.py -> build\lib.win32-2
.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helveticabold.py -> build\lib.win
32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helveticaboldoblique.py -> build\
lib.win32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helveticaoblique.py -> build\lib.
win32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_symbol.py -> build\lib.win32-2.7\
reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesbold.py -> build\lib.win32-2
.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesbolditalic.py -> build\lib.w
in32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesitalic.py -> build\lib.win32
-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesroman.py -> build\lib.win32-
2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_zapfdingbats.py -> build\lib.win3
2-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\__init__.py -> build\lib.win32-2.7\reportlab\pdfba
se

copying src\reportlab\pdfgen\canvas.py -> build\lib.win32-2.7\reportlab\pdfgen

copying src\reportlab\pdfgen\pathobject.py -> build\lib.win32-2.7\reportlab\pdfg
en

copying src\reportlab\pdfgen\pdfgeom.py -> build\lib.win32-2.7\reportlab\pdfgen

copying src\reportlab\pdfgen\pdfimages.py -> build\lib.win32-2.7\reportlab\pdfge
n

copying src\reportlab\pdfgen\pycanvas.py -> build\lib.win32-2.7\reportlab\pdfgen


copying src\reportlab\pdfgen\textobject.py -> build\lib.win32-2.7\reportlab\pdfg
en

copying src\reportlab\pdfgen\__init__.py -> build\lib.win32-2.7\reportlab\pdfgen


copying src\reportlab\platypus\doctemplate.py -> build\lib.win32-2.7\reportlab\p
latypus

copying src\reportlab\platypus\figures.py -> build\lib.win32-2.7\reportlab\platy
pus

copying src\reportlab\platypus\flowables.py -> build\lib.win32-2.7\reportlab\pla
typus

copying src\reportlab\platypus\frames.py -> build\lib.win32-2.7\reportlab\platyp
us

copying src\reportlab\platypus\para.py -> build\lib.win32-2.7\reportlab\platypus


copying src\reportlab\platypus\paragraph.py -> build\lib.win32-2.7\reportlab\pla
typus

copying src\reportlab\platypus\paraparser.py -> build\lib.win32-2.7\reportlab\pl
atypus

copying src\reportlab\platypus\tableofcontents.py -> build\lib.win32-2.7\reportl
ab\platypus

copying src\reportlab\platypus\tables.py -> build\lib.win32-2.7\reportlab\platyp
us

copying src\reportlab\platypus\xpreformatted.py -> build\lib.win32-2.7\reportlab
\platypus

copying src\reportlab\platypus\__init__.py -> build\lib.win32-2.7\reportlab\plat
ypus

copying src\reportlab\fonts\00readme.txt -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\bitstream-vera-license.txt -> build\lib.win32-2.7\re
portlab\fonts

copying src\reportlab\fonts\DarkGarden-copying-gpl.txt -> build\lib.win32-2.7\re
portlab\fonts

copying src\reportlab\fonts\DarkGarden-copying.txt -> build\lib.win32-2.7\report
lab\fonts

copying src\reportlab\fonts\DarkGarden-readme.txt -> build\lib.win32-2.7\reportl
ab\fonts

copying src\reportlab\fonts\DarkGarden.sfd -> build\lib.win32-2.7\reportlab\font
s

copying src\reportlab\fonts\DarkGardenMK.afm -> build\lib.win32-2.7\reportlab\fo
nts

copying src\reportlab\fonts\DarkGardenMK.pfb -> build\lib.win32-2.7\reportlab\fo
nts

copying src\reportlab\fonts\Vera.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\VeraBd.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\VeraBI.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\VeraIt.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_abi____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ab_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ai_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_a______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\cobo____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\cob_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\com_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\coo_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ebi____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_eb_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ei_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_er_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Sy______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Zd______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Zx______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Zy______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\lib\hyphen.mashed -> build\lib.win32-2.7\reportlab\lib

running build_ext

building '_rl_accel' extension

C:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Pytho
n27\PC -c C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel
.c -o c:\users\jj\documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.o

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c: In fun
ction `hex32':

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:491: wa
rning: unsigned int format, long unsigned int arg (arg 3)

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c: In fun
ction `_instanceStringWidthU':

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:741: wa
rning: 'L' might be used uninitialized in this function

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:741: wa
rning: 't' might be used uninitialized in this function

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:741: wa
rning: 'f' might be used uninitialized in this function

writing c:\users\jj\documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.d
ef

C:\mingw\bin\dllwrap.exe -mno-cygwin -mdll -static --output-lib c:\users\jj\docu
ments\build\reportlab\src\rl_addons\rl_accel\lib_rl_accel.a --def c:\users\jj\do
cuments\build\reportlab\src\rl_addons\rl_accel\_rl_accel.def -s c:\users\jj\docu
ments\build\reportlab\src\rl_addons\rl_accel\_rl_accel.o -LC:\Python27\libs -LC:
\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\_rl_accel.pyd

_rl_accel.exp: file not recognized: File format not recognized

collect2: ld returned 1 exit status

dllwrap: gcc exited with status 1

error: command 'dllwrap' failed with exit status 1
like image 945
jdotjdot Avatar asked Apr 23 '12 13:04

jdotjdot


2 Answers

So, after a while, I stumbled across a post that so far has worked for me.

http://www.develer.com/oss/GccWinBinaries

This site provides an unofficial MinGW GCC binary (not supported/endorsed by MinGW) that is meant to integrate perfectly with Python, down to the automatic updating of paths. I installed it and bam, pip install cython just started working.

Hope this helps more of you out there with this gcc problem.

like image 55
jdotjdot Avatar answered Oct 13 '22 05:10

jdotjdot


I've just answered the same question: why does dllwrap give this error within pip?

_foo.exp: file not recognized: File format not recognized

Short answer: check your PATH. MinGW\bin needs to be near the start of it.

Long answer: see python pip package install fails , dllwrap error after 'fixing': "unable to find vcvarsall.bat"

like image 41
Pete Forman Avatar answered Oct 13 '22 04:10

Pete Forman