I am trying to compile a Python library (CEGUI can build Python modules, its editor relies on that) that needs to link against boost-python. So I built boost, with --with-python and it built just fine.
However, as soon as the .pyd is linked, I get undefined references:
Linking CXX shared module ..\..\..\..\..\bin\PyCEGUI.pyd
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x97): undefined reference to `_imp___ZN5boost6python7objects10class_baseC2EPKcjPKNS0_9type_infoES4_'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x9c): undefined reference to `_imp___ZN5boost6python9converter8registry6insertEPFPvP7_objectEPFvS5_PNS1_30rvalue_from_python_stage1_dataEENS0_9type_infoEPFPK11_typeobjectvE
'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0xcc): undefined reference to `_imp___ZN5boost6python7objects23register_dynamic_id_auxENS0_9type_infoEPFSt4pairIPvS2_ES4_E'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0xf4): undefined reference to `_imp___ZN5boost6python7objects8add_castENS0_9type_infoES2_PFPvS3_Eb'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x1cd): undefined reference to `_imp___ZN5boost6python7objects17copy_class_objectERKNS0_9type_infoES4_'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x20d): undefined reference to `_imp___ZN5boost6python9converter8registry6insertEPFP7_objectPKvENS0_9type_infoEPFPK11_typeobjectvE'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x245): undefined reference to `_imp___ZN5boost6python7objects10class_base17set_instance_sizeEj'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x281): undefined reference to `_imp___ZN5boost6python7objects15function_objectERKNS1_11py_functionERKSt4pairIPKNS0_6detail7keywordES9_E'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x2f2): undefined reference to `_imp___ZN5boost6python7objects16add_to_namespaceERKNS0_3api6objectEPKcS5_S7_'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x348): undefined reference to `_imp___ZN5boost6python6detail13current_scopeE'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x4d1): undefined reference to `_imp___ZN5boost6python9converter8registry9push_backEPFPvP7_objectEPFvS5_PNS1_30rvalue_from_python_stage1_dataEENS0_9type_infoEPFPK11_typeobjectvE'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x636): undefined reference to `_imp___ZN5boost6python7objects16add_to_namespaceERKNS0_3api6objectEPKcS5_'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x1246): undefined reference to `_imp___ZN5boost6python6detail13current_scopeE'
CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):AbsoluteDim.pypp.cpp:(.text+0x1267): undefined reference to `_imp___ZN5boost6python6detail13current_scopeE'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: CMakeFiles\PyCEGUI.dir/objects.a(AbsoluteDim.pypp.cpp.obj):
bad reloc address 0x2 in section `.text$_ZN5boost6detail15sp_counted_baseD1Ev[__ZN5boost6detail15sp_counted_baseD1Ev]'
collect2.exe: error: ld returned 1 exit status
cegui\src\ScriptModules\Python\bindings\CMakeFiles\PyCEGUI.dir\build.make:6698: recipe for target 'bin/PyCEGUI.pyd' failed
mingw32-make[2]: *** [bin/PyCEGUI.pyd] Error 1
CMakeFiles\Makefile2:726: recipe for target 'cegui/src/ScriptModules/Python/bindings/CMakeFiles/PyCEGUI.dir/all' failed
mingw32-make[1]: *** [cegui/src/ScriptModules/Python/bindings/CMakeFiles/PyCEGUI.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
My first assumption was that it does not link against boost-python, but the link.txt inside the CMake folders shows this:
"C:\Coding\CMake 2.8\bin\cmake.exe" -E remove -f
CMakeFiles\PyCEGUI.dir/objects.a C:\MinGW\bin\ar.exe cr
CMakeFiles\PyCEGUI.dir/objects.a #CMakeFiles\PyCEGUI.dir\objects1.rsp
C:\MinGW\bin\g++.exe -shared -o ..........\bin\PyCEGUI.pyd
-Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\PyCEGUI.dir/objects.a -Wl,--no-whole-archive ..........\lib\libCEGUIBase-0.dll.a C:\Coding\boost_1_53_0\lib\libboost_python-mgw48-mt-1_53.a
C:\Python27\libs\python27.lib
C:\Coding\CEGUI\cegui\dependencies\lib\dynamic\libfreetype.dll.a
C:\Coding\CEGUI\cegui\dependencies\lib\dynamic\libpcre.dll.a -lwinmm
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
So boost-python is linked against.
I am unsure what could be the problem here. Boost? CEGUI? MinGW?...
Turns out, the problem was that I was using the 64bit version of Python. I downloaded it months ago and just forgot about that little fact.
Now, MinGW can only compile and use 32 bit libraries, not mix in 64 bit. This is what led to boost-python not compiling correctly (it's a wonder it did compile at all) and thus having undefined references when linked against.
Downloading the 32bit version of Python and recompiling boost solved the problems.
Related
I generated a C source file from my Python program with Cython. I was trying to compile it with GCC, but never succeed. The command I'm using currently is:
gcc -DSIZEOF_VOID_P=8 -DMS_WIN64 csv.c
-I"C:\Users\rudz3\AppData\Local\Programs\Python\Python39\include"
-L"C:\Users\rudz3\AppData\Local\Programs\Python\Python39\Lib"`
But I get errors about undefined references like the following:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\rudz3\AppData\Local\Temp\ccA4Bj2u.o:csv.c:(.text+0x6e): undefined reference to \`__imp__Py_Dealloc'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\rudz3\AppData\Local\Temp\ccA4Bj2u.o:csv.c:(.text+0x161): undefined reference to `__imp__PyType_Lookup'
I want to use Swig to use my C/C++ "model-controler" application with Python HMI.
I first test python swig simple example on my ubuntu PC and it works like a charm.
Then I tried to do the same on a Win7-64bits with Mingw-64:
"Wrap" by using
swig.exe -python path_to_swig_examples\python\simple\example
in cmd window, it's generate example_wrap.c… Ok
Then compile under mingw terminal (personally I launch by right-click in explorer then Git Bash here)
gcc -c -fPIC -DWIN32 example.c example_wrap.c -I/C/Program\ Files\ \(x86\)/Python36-32/include
generate my objs…Ok
and link
ld -shared example.o example_wrap.o -o _example.dll
and I have many undefined reference
example_wrap.o:example_wrap.c:(.text+0xe3): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0x1de): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0x5ff): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0x957): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0x98f): undefined reference to `strcpy'
example_wrap.o:example_wrap.c:(.text+0x9c8): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0xa38): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0xaaf): undefined reference to `strncpy'
example_wrap.o:example_wrap.c:(.text+0xaf5): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0xb11): undefined reference to `memset'
example_wrap.o:example_wrap.c:(.text+0xb57): undefined reference to `__imp_PyUnicode_AsUTF8String'
example_wrap.o:example_wrap.c:(.text+0xb76): undefined reference to `__imp_PyBytes_AsStringAndSize'
example_wrap.o:example_wrap.c:(.text+0xb88): undefined reference to `malloc'
example_wrap.o:example_wrap.c:(.text+0xbaa): undefined reference to `memcpy'
example_wrap.o:example_wrap.c:(.text+0xc15): undefined reference to `__imp_PyUnicode_FromString'
example_wrap.o:example_wrap.c:(.text+0xc69): undefined reference to `__imp_PyExc_MemoryError'
example_wrap.o:example_wrap.c:(.text+0xc7c): undefined reference to `__imp_PyExc_IOError'
example_wrap.o:example_wrap.c:(.text+0xc8f): undefined reference to `__imp_PyExc_RuntimeError'
example_wrap.o:example_wrap.c:(.text+0xca2): undefined reference to `__imp_PyExc_IndexError'
I added link to python36.dll (based on Anaconda3: https://www.continuum.io/downloads) /c/ProgramData/Anaconda3/python36.dll:
ld -shared example.o example_wrap.o /c/ProgramData/Anaconda3/python36.dll -o _example.dll
and python undefined msgs disappeared… but I have still C/C++ functions undefined reference …
…
ld -shared example.o example_wrap.o /c/ProgramData/Anaconda3/python36.dll /c/Windows/System32/msvcr120.dll -o _example.dll
and dll was created !
Thanks for is all the available swig+python+mingw compile information outdated?
… dll was created but doesn't works:
"ModuleNotFoundError: No module named '_example' "
swig no module named _example
then rename dll to pyd…
ImportError: DLL load failed: %1 is not a valid Win32 application
…was because it is python in 32 bits I ran.
Launch anaconda python:
C:\Program Data\Anaconda3\python.exe
Python 3.5.1 |Anaconda 4.4.0 (64-bit)…
>>> import example
>>> example.gcd(42,36)
6
>>> example.cvar.Foo
3.0
finally, it works… after much time spent !
Versions:
Windows 7 sp1
Swig 3.0.12
MingW-64
Anaconda3 4.4.0
gcc 6.2.0 / ld 2.25
Try to embed python3.6 in C++ on Win10 64bit system.
Python is installed by python-3.6.1-amd64.exe.
The CMakeList.txt is showing below
cmake_minimum_required(VERSION 3.8)
project(EmbedPython)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
add_executable(EmbedPython ${SOURCE_FILES} ${PYTHON_INCLUDE_DIRS})
target_link_libraries(EmbedPython ${PYTHON_LIBRARIES})
And CMake found the Python package.
PYTHON_INCLUDE_DIR C:/Program Files (x86)/Python36/include
PYTHON_LIBRARY C:/Program Files (x86)/Python36/libs/python36.lib
Find a comment on github it's talking about the API problem.
# used to embed python script
find_package(PythonLibs 2.7 REQUIRED) # this has to be 2.7 because the 3.0 API requires argv to be wchar_t** rather than the default char**
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries( assignment ${PYTHON_LIBRARIES})
The errors below is what I'm facing.
[ 50%] Building CXX object CMakeFiles/EmbedPython.dir/main.cpp.obj
[100%] Linking CXX executable EmbedPython.exe
CMakeFiles\EmbedPython.dir/objects.a(main.cpp.obj): In function `main':
D:/Projects/EmbedPython/main.cpp:16: undefined reference to `_imp__Py_Initialize'
D:/Projects/EmbedPython/main.cpp:17: undefined reference to `_imp__PyUnicode_DecodeFSDefault'
D:/Projects/EmbedPython/main.cpp:20: undefined reference to `_imp__PyImport_Import'
D:/Projects/EmbedPython/main.cpp:24: undefined reference to `_imp__PyObject_GetAttrString'
D:/Projects/EmbedPython/main.cpp:27: undefined reference to `_imp__PyCallable_Check'
D:/Projects/EmbedPython/main.cpp:28: undefined reference to `_imp__PyTuple_New'
D:/Projects/EmbedPython/main.cpp:30: undefined reference to `_imp__PyLong_FromLong'
D:/Projects/EmbedPython/main.cpp:38: undefined reference to `_imp__PyTuple_SetItem'
D:/Projects/EmbedPython/main.cpp:40: undefined reference to `_imp__PyObject_CallObject'
D:/Projects/EmbedPython/main.cpp:43: undefined reference to `_imp__PyLong_AsLong'
D:/Projects/EmbedPython/main.cpp:49: undefined reference to `_imp__PyErr_Print'
D:/Projects/EmbedPython/main.cpp:55: undefined reference to `_imp__PyErr_Occurred'
D:/Projects/EmbedPython/main.cpp:56: undefined reference to `_imp__PyErr_Print'
D:/Projects/EmbedPython/main.cpp:63: undefined reference to `_imp__PyErr_Print'
D:/Projects/EmbedPython/main.cpp:67: undefined reference to `_imp__Py_FinalizeEx'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [EmbedPython.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/EmbedPython.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/EmbedPython.dir/rule] Error 2
mingw32-make.exe: *** [EmbedPython] Error 2
CMakeFiles\EmbedPython.dir\build.make:96: recipe for target 'EmbedPython.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/EmbedPython.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/EmbedPython.dir/rule' failed
Makefile:117: recipe for target 'EmbedPython' failed
Not sure what to do to make the project run.Any help would be appreciated.
EDIT:
the result from make VERBOSE=1
D:\Projects\EmbedPython\cmake-build-debug>make VERBOSE=1
"C:\Program Files\JetBrains\CLion 172.2273.4\bin\cmake\bin\cmake.exe" -HD:\Projects\EmbedPython -BD:\Projects\EmbedPython\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\JetBrains\CLion 172.2273.4\bin\cmake\bin\cmake.exe" -E cmake_progress_start D:\Projects\EmbedPython\cmake-build-debug\CMakeFiles D:\Projects\EmbedPython\cmake-build-debug\CMakeFiles\progress.marks
make -f CMakeFiles\Makefile2 all
make[1]: Entering directory 'D:/Projects/EmbedPython/cmake-build-debug'
make -f CMakeFiles\EmbedPython.dir\build.make CMakeFiles/EmbedPython.dir/depend
make[2]: Entering directory 'D:/Projects/EmbedPython/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 172.2273.4\bin\cmake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" D:\Projects\EmbedPython D:\Projects\EmbedPython D:\Projects\EmbedPython\cmake-build-debug D:\Projects\EmbedPython\cmake-build-debug D:\Projects\EmbedPython\cmake-build-debug\CMakeFiles\EmbedPython.dir\DependInfo.cmake --color=
make[2]: Leaving directory 'D:/Projects/EmbedPython/cmake-build-debug'
make -f CMakeFiles\EmbedPython.dir\build.make CMakeFiles/EmbedPython.dir/build
make[2]: Entering directory 'D:/Projects/EmbedPython/cmake-build-debug'
[ 50%] Linking CXX executable EmbedPython.exe
"C:\Program Files\JetBrains\CLion 172.2273.4\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\EmbedPython.dir\link.txt --verbose=1
"C:\Program Files\JetBrains\CLion 172.2273.4\bin\cmake\bin\cmake.exe" -E remove -f CMakeFiles\EmbedPython.dir/objects.a
C:\PROGRA~2\MINGW-~1\I686-6~1.0-P\mingw32\bin\ar.exe cr CMakeFiles\EmbedPython.dir/objects.a #CMakeFiles\EmbedPython.dir\objects1.rsp
C:\PROGRA~2\MINGW-~1\I686-6~1.0-P\mingw32\bin\G__~1.EXE -g -Wl,--whole-archive CMakeFiles\EmbedPython.dir/objects.a -Wl,--no-whole-archive -o EmbedPython.exe -Wl,--out-implib,libEmbedPython.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\EmbedPython.dir\linklibs.rsp
CMakeFiles\EmbedPython.dir/objects.a(main.cpp.obj): In function `main':
D:/Projects/EmbedPython/main.cpp:16: undefined reference to `_imp__Py_Initialize'
D:/Projects/EmbedPython/main.cpp:17: undefined reference to `_imp__PyUnicode_DecodeFSDefault'
D:/Projects/EmbedPython/main.cpp:20: undefined reference to `_imp__PyImport_Import'
D:/Projects/EmbedPython/main.cpp:24: undefined reference to `_imp__PyObject_GetAttrString'
D:/Projects/EmbedPython/main.cpp:27: undefined reference to `_imp__PyCallable_Check'
D:/Projects/EmbedPython/main.cpp:28: undefined reference to `_imp__PyTuple_New'
D:/Projects/EmbedPython/main.cpp:30: undefined reference to `_imp__PyLong_FromLong'
D:/Projects/EmbedPython/main.cpp:38: undefined reference to `_imp__PyTuple_SetItem'
D:/Projects/EmbedPython/main.cpp:40: undefined reference to `_imp__PyObject_CallObject'
D:/Projects/EmbedPython/main.cpp:43: undefined reference to `_imp__PyLong_AsLong'
D:/Projects/EmbedPython/main.cpp:49: undefined reference to `_imp__PyErr_Print'
D:/Projects/EmbedPython/main.cpp:55: undefined reference to `_imp__PyErr_Occurred'
D:/Projects/EmbedPython/main.cpp:56: undefined reference to `_imp__PyErr_Print'
D:/Projects/EmbedPython/main.cpp:63: undefined reference to `_imp__PyErr_Print'
D:/Projects/EmbedPython/main.cpp:67: undefined reference to `_imp__Py_FinalizeEx'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\EmbedPython.dir\build.make:97: recipe for target 'EmbedPython.exe' failed
make[2]: *** [EmbedPython.exe] Error 1
make[2]: Leaving directory 'D:/Projects/EmbedPython/cmake-build-debug'
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/EmbedPython.dir/all' failed
make[1]: *** [CMakeFiles/EmbedPython.dir/all] Error 2
make[1]: Leaving directory 'D:/Projects/EmbedPython/cmake-build-debug'
Makefile:82: recipe for target 'all' failed
make: *** [all] Error 2
I had the exactly same problem, just with Python 3.7 while trying to build the example from the Python manual.
My system is a 64-bit Windows, the installed Python is a 64-bit 3.7 (from Anaconda3), and the compiler is a 32-bit MinGW 5.3.0 (from Qt 5.11).
The simplest solution that worked for me is the following:
Download Windows x86 embeddable zip file from this page.
Put the content of that archive to a folder inside the project you're building.
Do not install anything from that archive and do not put it on the system PATH.
Add the above folder to the gcc library search path, using: -L"path/to/folder/"
Add the python library to the linker, using -l"python37" ( replace 37 with whatever version you download)
As noted here (this was a hard one to find!), add a definition, using -DPy_BUILD_CORE_BUILTIN=1 (It is also possible to write #define DPy_BUILD_CORE_BUILTIN 1 just before #include-ing the Python header, though I would not recommend it)
Provide the path to the Python headers, using -I"path/to/include". I used the one from Anaconda, e.g. -I"c:/Users/user/Anaconda3/include/". Any installed header will do, just make sure its from the same version (headers from an older version might also be used, but this may cause a rupture in the space-time continuum)
Make sure that #include <Python.h> is before any other include, as stated in the manual.
As a side note, the MinGW linker (ld) is perfectly content, for many years now, if you just give it the "dll" file. No "lib", nor "a", is needed if you don't have one and only perform dynamic linking. This is why I just told the linker to use python37.
It it actually smart enough to look for files like python37.lib, python37.dll & libpython37.a.
Also note that the "embedable zip" is just the bare minimum needed for, well, embedding Python.
And as a last comment, contrary to what is stated here, there is no problem whatsoever linking from GCC with a library compiled using MSVS (and vice versa), as long as the library uses the plain C interface, since that interface is pretty much the only thing that is compatible across different compilers for any given platform.
This is pretty much the exact reason why Python is using the C interface (and nothing else, not even C++) for extending & embedding - to allow code written in any language, using any tool set, to interface with Python.
I had the same problem.
probably the problem is because of using 32 bit MinGW and 64 bit Python. you should install 32 bit version of python
Hope it will be useful to you :-)
I have successfully installed theano on Canopy EPD, windows 7, 64 bit. While importing theano (for testing at first time), I am getting this error. Can anybody help. Thanks.
It is similar to this question:
Installing Theano on EPD (Windows x64)
Exception: Compilation failed (return status=1): C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In function unpack_list_of_ssize_t':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:58: undefined reference to__imp_PyExc_TypeError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:68: undefined reference to __imp_PyExc_IndexError'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In functionCLazyLinker_init':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:341: undefined reference to __imp_PyCObject_Type'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:362: undefined reference to__imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:380: undefined reference to __imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:395: undefined reference to__imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:399: undefined reference to __imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:403: undefined reference to__imp_PyExc_IndexError'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o:C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:407: more undefined references to __imp_PyExc_IndexError' follow. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In functionCLazyLinker_init':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:415: undefined reference to __imp_PyExc_TypeError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:430: undefined reference to__imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:436: undefined reference to __imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:450: undefined reference to__imp_PyExc_TypeError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:454: undefined reference to __imp__Py_NoneStruct'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In functionc_call':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:555: undefined reference to __imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:555: undefined reference to__imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:555: undefined reference to __imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:556: undefined reference to__imp__Py_NoneStruct'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o:C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:556: more undefined references to __imp__Py_NoneStruct' follow. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In functionlazy_rec_eval':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:628: undefined reference to __imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:651: undefined reference to__imp_PyExc_TypeError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:659: undefined reference to __imp_PyExc_ValueError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:667: undefined reference to__imp_PyExc_IndexError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:718: undefined reference to __imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:725: undefined reference to__imp_PyExc_TypeError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:731: undefined reference to __imp_PyExc_TypeError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:781: undefined reference to__imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:781: undefined reference to __imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:782: undefined reference to__imp__Py_NoneStruct'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In function CLazyLinker_call':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:817: undefined reference to__imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:817: undefined reference to __imp__Py_NoneStruct'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o:C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:818: more undefined references to__imp__Py_NoneStruct' follow. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In function CLazyLinker_call':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:867: undefined reference to__imp_PyExc_AssertionError'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:910: undefined reference to __imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:910: undefined reference to__imp__Py_NoneStruct'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:911: undefined reference to __imp__Py_NoneStruct'. C:\Users\HARISH~1\AppData\Local\Temp\ccLHOaX7.o: In functionCLazyLinker_set_allow_gc':. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:943: undefined reference to __imp_PyBool_Type'. C:/Users/Harish-Chandra/AppData/Local/Theano/compiledir_Windows-8-6.2.9200-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.9-64/lazylinker_ext/mod.cpp:946: undefined reference to__imp__Py_TrueStruct'. collect2: ld returned 1 exit status.
Since this question wasnt properly closed by the author and it's also relevant to most EPD users, including me when i first started with EPD + theano, i will answer to it.
First, remove any other python environment if possible.
Be sure there is no other conflicting environment path of python, just in case.
1.Install EPD CANOPY
2.Install the MinGW package that is on package installer available on Canopy application
That should be easy to do, you just open the package manager from inside the Canopy application.
3.Install Theano from inside EPD
Before you go spamming
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
in every prompt of command you see, DONT DO IT.
--
Instead, Open Canopy.
In Canopy screen, go to "Tools", and then open "Canopy Command Prompt"
A screen exactly like the CMD from windows will open.
On that screen, execute :
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Should work fine now.
--
However, dont forget you will need , obviously the Windows SDK , depending on the windows version of course.
You can try installing the last Visual Studio with comes with everything you need.
If you need more info on this, check this related Stackoverflow topic :
Installing theano
I am trying to compile a pyx code to obtain a pyd/dll file for python on my Windows 64 machine. I am doing it step by step in the command window to figure out where it is going wrong.
I successfully converted the pyx into a c file called samplers.c. Then into a .o file. I am at the last step I believe in compiling a shared object (pyd), but for some reason the compiler cannot read what is inside the gsl_rng.h file. It is clearly included as one of the directories in the gsl library, but for some reason cannot find them and throws the undefined reference error. I've even included -lgsl -lgslcblas -lm as a lot of forum posts suggest, but still no dice.
c:\Users\MyName\Anaconda\conda-bld\work>C:\TDM-GCC-64\bin\gcc.exe -DMS_WIN64 -shared -s samplers.o build\temp.win-amd64-2.7\Release\samplers.def -LC:\Users\MyName\Anaconda\gsl\lib -LC:\Users\MyName\Anaconda\libs -LC:\Users\MyName\Anaconda\PCbuild\amd64-lgsl -lgslcblas -lm -lpython27 -lmsvcr90 -o c:\Users\MyName\Anaconda\conda-bld\work\samplers.pyd
samplers.o:samplers.c:(.text+0x1f73): undefined reference to `gsl_rng_uniform'
samplers.o:samplers.c:(.text+0x20a91): undefined reference to `gsl_rng_mt19937'
samplers.o:samplers.c:(.text+0x20a96): undefined reference to `gsl_rng_alloc'
samplers.o:samplers.c:(.text+0x20c75): undefined reference to `gsl_rng_set'
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw /bin/ld.exe: samplers.o: bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status
... -LC:\Users\MyName\Anaconda\PCbuild\amd64-lgsl ...
Individual arguments to a command must be separated by a space, in this case the -L and -l arguments.