g++ error on import of Theano on Windows 7
Asked Answered
F

6

8

I'm attempting to get setup with a proper g++ installation according to the theano installation guide. I've previously had theano working with the python only implementation. I'm using the bleeding edge version of theano from their git repo on python 3.4. I've tried using the theano suggested TDM-GCC-64 method as well as MinGW, and both result in the exact same error. (copied as readable as possible)

Problem occurred during compilation with the command line below:
C:\MinGW\bin\g++.exe -shared -g -march=skylake -mmmx -mno-3dnow -msse -msse2 -msse3 
-mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt 
-mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx 
-mavx2 -msse4.2 -msse4.1 -mlzcnt -mrtm -mhle -mrdrnd -mf16c -mfsgsbase 
-mrdseed -mprfchw -madx -mfxsr -mxsave -mxsaveopt -mno-avx512f 
-mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mclflushopt 
-mxsavec -mxsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl 
-mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx 
-mno-clzero -mno-pku --param l1-cache-size=32 --param 
l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=skylake 
-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 
-IC:\Python34_64bit\lib\site-packages\numpy\core\include
IC:\Python34_64bit\include -IC:\Python34_64bit\lib\site-packages\theano\gof
-o C:\Users\Jwely\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.4.4-64\lazylinker_ext\lazylinker_ext.pyd 
C:\Users\Jwely\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.4.4-64\lazylinker_ext\mod.cpp 
-LC:\Python34_64bit\libs -LC:\Python34_64bit -lpython34


In file included from c:\mingw\include\c++\6.1.0\math.h:36:0,
from C:\Python34_64bit\include/pyport.h:328,
from C:\Python34_64bit\include/Python.h:50,
from C:\Users\Jwely\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-3.4.4-64\lazylinker_ext\mod.cpp:1:
c:\mingw\include\c++\6.1.0\cmath:1133:11: error: '::hypot' has not been declared
    using ::hypot;
            ^~~~~

It may be worth noting that before it prints this error, it prints an entire file worth of code, you can find the entire error output here

I'm not sure what to try next, I've followed the directions twice, used a couple different installation methods for some dependencies, and made sure to clean up my system path between each attempt and reboot.

Flatfooted answered 22/7, 2016 at 23:58 Comment(0)
E
29

This worked for me:

  1. Go to your user folder: C:/Users/[username]
  2. Create .theanorc file if it doesn't already exist
  3. makes sure it includes the lines:

    [gcc]
    cxxflags = -D_hypot=hypot
    
Edith answered 4/10, 2016 at 4:57 Comment(4)
Don't know why this why downvoted, great fix, unless I'm missing something.Palikar
How am I supposed to create a file without a name? Windows doesn't allow me to.Anglesite
Ah, found it out here: #5005133Anglesite
export CXXFLAGS=-D_hypot=hypotTherontheropod
J
4

"Error: '::hypot' has not been declared" in cmath while trying to embed Python Error building Boost 1.49.0 with GCC 4.7.0

my solution is comment out all the

#define hypot _hypot

macro in the pyconfig.h file

Jerrold answered 28/7, 2016 at 3:3 Comment(1)
This worked for me.... but I wonder if other applications could have problems with the absence of "_hypot".Anglesite
D
0

This worked for me

  1. Go to System properties/Advance system setting
  2. Add your MinGW installation path, if already added and looks something like C:\{your MingW installation}\bin change it to C:\{your MingW installation}
Detection answered 27/3, 2017 at 4:38 Comment(0)
E
0

The answers above are probably a better, more permanent solution. For a quick fix, the following worked for me:

import theano
theano.config.gcc.cxxflags = "-D_hypot=hypot"

...with Windows 10, Anaconda 4.4, Python 2.7, Theano v0.10.0.dev1, m2w64-toolchain v5.3.0

Emilemile answered 12/6, 2017 at 13:50 Comment(1)
If you add the quotes marks it gives you an error: g++.exe: error: "-D_hypot=hypot". Invalid argumentNonconformance
S
0

if you can't create a file with name .theanorc.
You can use this code in console but before open cmd in C:/Users/[username] and then write python and then paste below code there:

import os
with open(os.path.join(os.environ["USERPROFILE"], ".theanorc"), "w") as f:
    f.write("[gcc]\ncxxflags = -D_hypot=hypot")
Slander answered 23/10, 2018 at 8:16 Comment(0)
S
-1

First, uninstall all Theano versions.

Then:

pip install pydot-ng

conda install mingw libpython

pip install git+https://github.com/Theano/Theano.git#egg=Theano
Schwarzwald answered 3/7, 2017 at 11:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.