Generally, where is the x.o file stored when x.cpp and x.h are compiled?
Specifically, how to fix the error
megatron/fused_kernels/scaled_upper_triang_masked_softmax.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
when running python ./megatron/fused_kernels/setup.py install?
The .o file is included in the .exe/.out file if you don't compile the .cpp file with the -c compiler flag. But if you use the -c compiler flag, it is stored in the same directory as the .cpp file.
Related
First I downloaded the .whl file for Cython from the pythonlibs website, then I open up my bash terminal and execute the following command:
python install Cython
here is the output:
unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools,
If it helps, my operating system is windows 10, thanks
I am trying to execute a file as shown on this website,
http://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html
I have saved my file with .pyx extension, made the setup.py file and ran python setup.py build_ext --inplace command. So earlier I was getting error: command 'gcc' failed: No such file or directory and then I installed the package as suggested here Error: command 'gcc' failed: No such file or directory I added the C:\users\name\mingw\bin in my environment variable as suggested MinGW: "gcc is not recognized as an internal or external command".
Still, when I am typing gcc on cmd it is showing 'gcc' is not recognized as an internal or external command,operable program or batch file.
So, I am confused. I also went into mingw\bin and then I run python setup.py build_ext --inplace but then I get command 'gcc.exe' failed with exit status 1.
I am stuck on this. Please help as this is my first time to use Cython.
I am using anaconda py3.6, with conda's mingw32.
I set mingw32 as the compiler, also modified cygwinccompiler.py as suggested in Building minimal cython file with python 3.3 (Anaconda) under windows 7 .
Now I still can't build any binary pyd module, they all failed at the linking step with similar error.
C:\ProgramData\Anaconda3\Scripts\gcc.bat -shared -s build\temp.win32-3.6\Release\cymysql\packet.o build\temp.win32-3.6\Release\cymysql\packet.cp36-win32.def -LC:\ProgramData\Anaconda3\libs -LC:\ProgramData\Anaconda3\PCbuild\win32 -lpython36 -lmsvcr140 -o build\lib.win32-3.6\cymysql\packet.cp36-win32.pyd c:/programdata/anaconda3/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/bin/ld.exe: build\temp.win32-3.6\Release\cymysql\packet.cp36-win32.def:1: syntax error
c:/programdata/anaconda3/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/bin/ld.exe:build\temp.win32-3.6\Release\cymysql\packet.cp36-win32.def: file format not recognized; treating as linker script
c:/programdata/anaconda3/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/bin/ld.exe:build\temp.win32-3.6\Release\cymysql\packet.cp36-win32.def:1: syntax error
collect2.exe: error: ld returned 1 exit status error: command 'C:\\ProgramData\\Anaconda3\\Scripts\\gcc.bat' failed with exit status 1
another example:
(base) D:\pymssql-build\pymssql>gcc -shared -s build\temp.win32-3.6\Release\_mssql.o build\temp.win32-3.6\Release\_mssql.cp36-win32.def -LC:\ProgramData\Anaconda3\Library\mingw-w64\lib -LC:\ProgramData\Anaconda3\Library\lib -LD:\pymssql-build\pymssql\freetds\ming_32\lib-nossl -LC:\ProgramData\Anaconda3\libs -LC:\ProgramData\Anaconda3\PCbuild\win32 -llibiconv -liconv -lsybdb -lws2_32 -lwsock32 -lkernel32 -lpython36 -lmsvcr140 -o build\lib.win32-3.6\_mssql.cp36-win32.pyd
c:/programdata/anaconda3/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/bin/ld.exe: build\temp.win32-3.6\Release\_mssql.cp36-win32.def:1: syntax error
c:/programdata/anaconda3/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/bin/ld.exe:build\temp.win32-3.6\Release\_mssql.cp36-win32.def: file format not recognized; treating as linker script
c:/programdata/anaconda3/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/bin/ld.exe:build\temp.win32-3.6\Release\_mssql.cp36-win32.def:1: syntax error
collect2.exe: error: ld returned 1 exit status
While the def files looks just fine to me:
LIBRARY _mssql.cp36-win32.pyd
EXPORTS
PyInit__mssql
_mssql.o size: 507kb
Trying to install a compiled Python package on a 64-bit Windows machine using MinGW compiler. The same install succeeded on my 32-bit machine but failed on two different 64-bit machines:
C:\Python\Scripts> pip install python-Levenshtein
C:\Python\libs/python33.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Trying from a cloned copy:
$ python setup.py build
C:\Python\libs/python33.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Running the build command by itself:
$ gcc.exe -shared -s 'build\temp.win-amd64-3.3\Release\levenshtein\_levenshtein.o' 'build\temp.win-amd64-3.3\Release\levenshtein\_levenshtein.def' -LC:'\Python\libs' -LC:'\Python\PCbuild\amd64' -lpython33 -lmsvcr100 -o 'build\lib.win-amd64-3.3\Levenshtein\_levenshtein.pyd'
C:\Python\libs/python33.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
$ file 'C:\Python\libs/python33.lib'
C:\Python\libs/python33.lib: current ar archive
Thank you
- Muposat
I'm confused. I have installed pyodbc on my computer and I was able to import it using other IDE
but i'm new to ipython.
I use Ananconda , and was able to install other library using something like
pip install BeautifulSoup
But when I do that with pyodbc using
pip install pyodbc
I got error :
error: command 'gcc' failed with exist status 1
C:\Users\jeannie.chirayu>pip install pyodbc
Downloading/unpacking pyodbc
You are installing a potentially insecure and unverifiable file. Future versio
ns of pip will default to disallowing insecure files.
Downloading pyodbc-3.0.7.zip (85kB): 85kB downloaded
Running setup.py egg_info for package pyodbc
warning: no files found matching 'tests\*'
Installing collected packages: pyodbc
Running setup.py install for pyodbc
building 'pyodbc' extension
C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7
-IC:\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni~1.chi\appdata\local\t
emp\pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni~1.chi\app
data\local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4
820 /wd4711 /wd4100 /wd4127 /wd4191
gcc.exe: error: /Wall: No such file or directory
gcc.exe: error: /wd4668: No such file or directory
gcc.exe: error: /wd4820: No such file or directory
gcc.exe: error: /wd4711: No such file or directory
gcc.exe: error: /wd4100: No such file or directory
gcc.exe: error: /wd4127: No such file or directory
gcc.exe: error: /wd4191: No such file or directory
error: command 'gcc' failed with exit status 1
Complete output from command C:\Anaconda\python.exe -c "import setuptools;__
file__='c:\users\jeanni~1.chi\appdata\local\temp\pip_build_jeannie.chirayu
\pyodbc\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), __
file__, 'exec'))" install --record c:\users\jeanni~1.chi\appdata\local\temp\pip-
lqnyba-record\install-record.txt --single-version-externally-managed:
running install
running build
running build_ext
building 'pyodbc' extension
C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC
:\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni~1.chi\appdata\local\temp\
pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni~1.chi\appdata
\local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4820
/wd4711 /wd4100 /wd4127 /wd4191
gcc.exe: error: /Wall: No such file or directory
gcc.exe: error: /wd4668: No such file or directory
gcc.exe: error: /wd4820: No such file or directory
gcc.exe: error: /wd4711: No such file or directory
gcc.exe: error: /wd4100: No such file or directory
gcc.exe: error: /wd4127: No such file or directory
gcc.exe: error: /wd4191: No such file or directory
error: command 'gcc' failed with exit status 1
Cleaning up...
Command C:\Anaconda\python.exe -c "import setuptools;file='c:\users\jeanni
~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc\setup.py';exec(
compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install
--record c:\users\jeanni~1.chi\appdata\local\temp\pip-lqnyba-record\install-rec
ord.txt --single-version-externally-managed failed with error code 1 in c:\users
\jeanni~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc
Storing complete log in C:\Users\j\pip\pip.log
Any recommendation would help. Thanks.
this was annoying. but i got it working. basically, pyodbc source code is missing a lot of crap.
1) in the pyodbc directory, open setup.py and search for "wd4668".
change that list to look like this:
settings['extra_compile_args'] = []
2) in the src directory, create a file called "abc_minmax.h". in it, put:
#ifndef min
#define min(a, b) ((a < b) ? a : b)
#define max(a, b) ((a > b) ? a : b)
#endif
3) in the following files in the src directory:
cursor.h
params.h
sqlwchar.h
add the following line near the other includes at the top:
#include "abc_minmax.h"
4) finally, in the file wrapper.h, add the following 2 lines near the other includes:
#include <Windows.h>
#include <Winreg.h>
ok, that should do it! let me know if something doesn't work.
It won't help with the pip install issues but you could download the .exes from https://code.google.com/p/pyodbc/
or
http://www.lfd.uci.edu/~gohlke/pythonlibs/