error: command 'gcc' failed with exit status 1
Landau1908 opened this issue · comments
Hey, Thomas
Up to now, I have finished the first two steps. However, in the last step, that is "install CpyMAD", I got into trouble again.
According to the recommendation, I run the commands in CMD: python setup.py install --madxdir=<madx-install-path>
.
i.e. D:\install\Windows-setup\pymad-cpymad-4cf406c>python setup.py install --madxdir=D: \install\Windows-setup\madX
And then, the error occurs: error: Unable to find vcvarsall.bat
, as the troubleshooting mentioned.
Next, I run the commands on the command line: D:\install\Windows-setup\pymad-cpymad-4cf406c>python setup.py build --madxdir=D:\install\Windows-setup\madX --compiler=mingw32
as recommended in the Troubleshooting.
I don't use the first method, which needs to add another lines to the C:\python27\Lib\distutils\distutils.cfg
, since I can't find out distutils.cfg everywhere in my computer.
After that, an error occurs again, saying as below:
D:\install\Windows-setup\pymad-cpymad-4cf406c>python setup.py build --madxdir=D:
\install\Windows-setup\madX --compiler=mingw32
missing cimport in module 'cern.cpymad.clibmadx': src/cern/cpymad/libmadx.pyx
running build
running build_py
running egg_info
writing requirements to src\cern_cpymad.egg-info\requires.txt
writing src\cern_cpymad.egg-info\PKG-INFO
writing namespace_packages to src\cern_cpymad.egg-info\namespace_packages.txt
writing top-level names to src\cern_cpymad.egg-info\top_level.txt
writing dependency_links to src\cern_cpymad.egg-info\dependency_links.txt
reading manifest file 'src\cern_cpymad.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'requirements.txt'
writing manifest file 'src\cern_cpymad.egg-info\SOURCES.txt'
running build_ext
building 'cern.cpymad.libmadx' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\src
creating build\temp.win32-2.7\Release\src\cern
creating build\temp.win32-2.7\Release\src\cern\cpymad
D:\Program Files\MinGW32-xy\bin\gcc.exe -mno-cygwin -mdll -O -Wall -DMAJOR_VERSI
ON=0 -DMINOR_VERSION=8 -ID:\install\Windows-setup\madX\include "-ID:\Program Fil
es\python\include" "-ID:\Program Files\python\PC" "-ID:\Program Files\python\lib
\site-packages\numpy\core\include" -c src/cern/cpymad/libmadx.c -o build\temp.wi
n32-2.7\Release\src\cern\cpymad\libmadx.o
gcc: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
B.t.w, the built versions seems to be invalid. when I click on the link it says Not found
.
Hey,
I encountered this problem once before, but not with the compiler suite installed by python-xy, which is why I didnt include in the documentation. I will update the docs accordingly.
The fix is as follows: In the file C:\Python27\Lib\distutils\cygwinccompiler.py
delete every occurence of the string -mno-cygwin
in the class Mingw32CCompiler
(about line120):
EDIT: oops wrong line number. Real line number is about 320!
Depending on your version on distutils, for example:
@@ -319,11 +319,11 @@ class Mingw32CCompiler (CygwinCCompiler):
else:
entry_point = ''
- 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.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))
# Maybe we should also append -mthreads, but then the finished
or
if self.gcc_version < '4' or is_cygwingcc():
- no_cygwin = ' -mno-cygwin'
+ no_cygwin = ''
else:
no_cygwin = ''
Furthermore, I noticed that you substituted <madx-install-dir> = D: \install\Windows-setup\madX
. However, you need to use the path as specified by -DCMAKE_INSTALL_PREFIX
. I.e. if you followed the recommendations, it should be:
python setup.py install --madxdir=D: \install\Windows-setup\madX\install --compiler=mingw32
Hope this helps. Thomas.
I don't use the first method, which needs to add another lines to the
C:\python27\Lib\distutils\distutils.cfg
, since I can't find outdistutils.cfg
everywhere in my computer.
If it doesn't exist, you need to create the file distutils.cfg
in the folder C:\Python27\Lib\distutils
or wherever you installed your python to.
Hey, Thomas
I don't know how to modify my distutils, whch is different from yours. Sorry, I know little about this. Below is my distutils, containg class Mingw32CCompiler
only.
# class CygwinCCompiler
# the same as cygwin plus some additional parameters
class Mingw32CCompiler (CygwinCCompiler):
compiler_type = 'mingw32'
def __init__ (self,
verbose=0,
dry_run=0,
force=0):
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
# ld_version >= "2.13" support -shared so use it instead of
# -mdll -static
if self.ld_version >= "2.13":
shared_option = "-shared"
else:
shared_option = "-mdll -static"
# A real mingw32 doesn't need to specify a different entry point,
# but cygwin 2.91.57 in no-cygwin-mode needs it.
if self.gcc_version <= "2.91.57":
entry_point = '--entry _DllMain@12'
else:
entry_point = ''
if self.gcc_version < '4' or is_cygwingcc():
no_cygwin = ' -mno-cygwin'
else:
no_cygwin = ''
self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
compiler_cxx='g++%s -O -Wall' % no_cygwin,
linker_exe='gcc%s' % no_cygwin,
linker_so='%s%s %s %s'
% (self.linker_dll, no_cygwin,
shared_option, entry_point))
# Maybe we should also append -mthreads, but then the finished
# dlls need another dll (mingwm10.dll see Mingw32 docs)
# (-mthreads: Support thread-safe exception handling on `Mingw32')
# no additional libraries needed
self.dll_libraries=[]
# Include the appropriate MSVC runtime library if Python was built
# with MSVC 7.0 or later.
self.dll_libraries = get_msvcr()
# __init__ ()
# class Mingw32CCompiler
# Because these compilers aren't configured in Python's pyconfig.h file by
# default, we should at least warn the user if he is using a unmodified
# version.
Did you try to replace the line that reads:
no_cygwin = ' -mno-cygwin'
by
no_cygwin = ''
as suggested by the second diff in my post before?
BTW: I have now updated the install recommendations to be more thorough about the points where you had problems so far.
Yes, I replace it as you do, but the error still exists.
command 'gcc' failed with exit status 1
Still with the
gcc: error: unrecognized command line option '-mno-cygwin'
error?
Can you open the enhanced terminal and execute python
, then:
>>> import sys
>>> print(sys.executable)
And send me the output?
BTW, do you have jabber/IM for faster communication?
below is the error:
D:\install\Windows-setup\pymad-cpymad-4cf406c>python setup.py install --madxdir=
D:\install\Windows-setup\madX\install
missing cimport in module 'cern.cpymad.clibmadx': src/cern/cpymad/libmadx.pyx
running install
running bdist_egg
running egg_info
writing requirements to src\cern_cpymad.egg-info\requires.txt
writing src\cern_cpymad.egg-info\PKG-INFO
writing namespace_packages to src\cern_cpymad.egg-info\namespace_packages.txt
writing top-level names to src\cern_cpymad.egg-info\top_level.txt
writing dependency_links to src\cern_cpymad.egg-info\dependency_links.txt
reading manifest file 'src\cern_cpymad.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'requirements.txt'
writing manifest file 'src\cern_cpymad.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
running build_ext
building 'cern.cpymad.libmadx' extension
D:\Program Files\MinGW32-xy\bin\gcc.exe -mdll -O -Wall -DMAJOR_VERSION=0 -DMINOR
_VERSION=8 -ID:\install\Windows-setup\madX\install\include "-ID:\Program Files\p
ython\include" "-ID:\Program Files\python\PC" "-ID:\Program Files\python\lib\sit
e-packages\numpy\core\include" -c src/cern/cpymad/libmadx.c -o build\temp.win32-
2.7\Release\src\cern\cpymad\libmadx.o
In file included from D:\Program Files\python\lib\site-packages\numpy\core\inclu
de/numpy/ndarraytypes.h:1761:0,
from D:\Program Files\python\lib\site-packages\numpy\core\inclu
de/numpy/ndarrayobject.h:17,
from D:\Program Files\python\lib\site-packages\numpy\core\inclu
de/numpy/arrayobject.h:4,
from src/cern/cpymad/libmadx.c:346:
D:\Program Files\python\lib\site-packages\numpy\core\include/numpy/npy_1_7_depre
cated_api.h:12:9: note: #pragma message: D:\Program Files\python\lib\site-packag
es\numpy\core\include/numpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Using de
precated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VE
RSION
#pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it by " \
^
src/cern/cpymad/libmadx.c:348:26: fatal error: madX/mad_def.h: No such file or d
irectory
#include "madX/mad_def.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
D:\install\Windows-setup\pymad-cpymad-4cf406c>
output:
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import sys
>>> print (sys.executable)
D:\Program Files\python\pythonw.exe
>>>
sorry I don't know jabber.
This is a different error, meaning the first problem is fixed. It indicates that either the <madx-install-path>
you used is incorrect or the make install
command from the build libmadx step did not succeed.
In #76 you posted install log according to which you should substitute --madxdir="D:\install\Windows setup\madX.r4920\install"
. Please check that the path from the argument exists and contains subfolders include
, bin
, lib
.
To speed things up, you should always try to check whether my answers fix your original error and then post updated information, so I don't need to ask whether you really got the same message again.
OK, I will check the path and try it again. thank for your attention!
Hey, Thomas
I think I have finished install. Thanks for your warm help. Below is the command line output:
......
removing 'build\bdist.win32\egg' (and everything under it)
Processing cern_cpymad-0.8-py2.7-win32.egg
creating d:\program files\python\lib\site-packages\cern_cpymad-0.8-py2.7-win32.e
gg
Extracting cern_cpymad-0.8-py2.7-win32.egg to d:\program files\python\lib\site-p
ackages
Adding cern-cpymad 0.8 to easy-install.pth file
Installed d:\program files\python\lib\site-packages\cern_cpymad-0.8-py2.7-win32.
egg
Processing dependencies for cern-cpymad==0.8
Searching for PyYAML==3.11
Best match: PyYAML 3.11
Adding PyYAML 3.11 to easy-install.pth file
Using d:\program files\python\lib\site-packages
Searching for numpy==1.8.1
Best match: numpy 1.8.1
Adding numpy 1.8.1 to easy-install.pth file
Using d:\program files\python\lib\site-packages
Finished processing dependencies for cern-cpymad==0.8
D:\install\Windows-setup\pymad-cpymad>
Great. Keep in mind, that this package is still in development, and if you have questions or suggestions, just go ahead and open an issue;).
Thomas