I try to cross-compile libplist (https://github.com/libimobiledevice/libplist) for 64-bit Windows and create a DLL from it. I downloaded mingw-w64 for Linux subsystem on Windows 10 (Ubuntu 14.04 bash) and set the environment variables (CC, CXX, CPP, RANLIB). I use ./autogen.sh --host=x86_64-w64-mingw32 to configure package. However it exits with the error:
configure:16825: error:
Could not link test program to Python. Maybe the main Python library has been
installed in some non-standard library path. If so, pass it to configure,
via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
In config.log it says:
configure:16813: x86_64-w64-mingw32-gcc -o conftest.exe -g -O2 -I/usr/include/python2.7 -I/usr/include/x86_64-linux-g$
In file included from /usr/include/python2.7/Python.h:8:0,
from conftest.c:33:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch location for pyconfig.h
# error unknown multiarch location for pyconfig.h
^
In file included from /usr/include/python2.7/pyport.h:4:0,
from /usr/include/python2.7/Python.h:58,
from conftest.c:33:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch location for pyconfig.h
# error unknown multiarch location for pyconfig.h
^
In file included from /usr/include/python2.7/pymath.h:4:0,
from /usr/include/python2.7/Python.h:77,
from conftest.c:33:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch location for pyconfig.h
# error unknown multiarch location for pyconfig.h
^
configure:16813: $? = 1
It doesn't return this error when I try to compile it for Linux, so I thought that it's because it needs python libraries compiled for Windows x86_64. I copied the appropriate files from Windows from C:/Python27/include and tried to set environment variable for configuration LDFLAGS="-L/path/to/python/include" and PKG_CONFIG_PATH=/path/to/python/include separately. Neither of them worked. I also noticed, that in C:/Python27/include there was also a file called pyconfig.h.Why does the script uses the one installed on Linux? Is there a way I could force it to use the other one?
My main objective would be to make a 64-bit Windows DLL from libusbmuxd (https://github.com/libimobiledevice/libusbmuxd), but it needs libplist to be compiled too. How could I solve this issue? Thanks for the answers in advance.
You can try libimobiledevice-win32. Although the name is a bit confusing, it builds 32-bit and 64-bit Windows versions of libimobiledevice.
You can compile libplist, libusbmuxd, libimobildevice and the various utilities for Windows using Visual Studio, avoiding the need to cross compile.
The company I work for, Quamotion, maintains libimobiledevice-win32 and we try to stay on track with the latest upstream changes.
You can download precompiled versions from the CI build, see e.g. https://ci.appveyor.com/project/qmfrederik/imobiledevice-net/build/artifacts for zip files which contain the latest bits.
For a schoolproject I need to make use of the aubio library. However, I have a problem compiling it for Windows.
I downloaded the latest source from his git (0.4.0 alpha). Then I compiled it using Cygwin, using the --with-target-platform=win32 to cross-compile it for Windows. It uses waf by the way.
This works without any errors.
Next step is copying the compiled file (libaubio.dll.a) to MinGW library folder. Then I want to compile the Python wrapper for the module, but it shows up the ld.exe cannot find -laubio error. Renaming the libaubio.dll.a to libaubio.a resolves this and compiling succeeds succesfully.
Installing it into the Python folder works perfectly too. But here starts the problem. When trying to import aubio, I get this error: ImportError: DLL load failed: Invalid access to memory location.
I have no clue on how to solve this problem. Can anybody help? Or explain the error to me?
Thanks in advance!
Xander
PS. It compiles perfectly on both OSX and Ubuntu.
Well, this may not be the right solution for you, just a hint. ImportError: DLL load failed: Invalid access to memory location. I encountered the same error when trying to make my own extension of Python programmed in C. Platform: Windows 32bits.
It was a real pain because this error appeared randomly in interactive as well as in non-interactive mode in all Python environments (Spyder, Notebook, plain console...). I compiled my code using MinGW and Python's distutils (command python setup.py install). The compilation gave no warnings or errors and produced pyd file to the correct directory. But when trying to import this module import example pro my Python code it irregularly crashed (usually only one out of five attempts to import the module succeeded).
Strange was that on another computer it worked just fine... Well, finally I found workaround - I downloaded a newer version of MinGW (before I had used the version that comes packed in Qt SDK distribution) and compiled the module again. Then it worked with no more crashes. However I did not find any systematic solution or explanation. So I might have something to do with the compiler (maybe absence of its DLLs? I do not know exactly) that was used to generate the pyd file.
I'd like to use graph-tool on windows 7, but I'm having trouble installing it.
All the requirements listed here are successfully installed. Python 2.7 is installed in C:\python27. Boost 1.49.0 was successfully compiled with mingw, installed in C:\boost and the BOOST_ROOT environment variable is pointing to it. Boost is compiled in debug and release mode and both static and dynamic.
Invoking configure from within MSyS leads to the following error.
configure: error:
Could not link test program to Python. Maybe the main Python library has been
installed in some non-standard library path. If so, pass it to configure,
via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
Calling configure LDFLAGS="-LC:/python27/libs" fixed this error, but lead to the following error
checking for boostlib >= 1.38.0... configure: error: We could not detect the boo
st libraries (version 1.38 or higher). If you have a staged boost library (still
not installed) please specify $BOOST_ROOT in your environment and do not give a
PATH to --with-boost option. If you are sure you have boost installed, then ch
eck your version number looking in <boost/version.hpp>. See http://randspringer.
de/boost for more documentation.
This is weird, since BOOST_ROOT is clearly defined (checked it with printenv command).
The next command I tried was configure --with-boost="C:/boost" LDFLAGS="-LC:/python27/libs"
checking for boostlib >= 1.38.0... yes
checking whether the Boost::Python library is available... no
configure: error: No usable boost::python found
Alright it detects boost, but It can't find boost::python. Due to its size I'm unable to post the config.log on stackoverflow but you can find it here.
I'm really confused right now and would appreciate any help.
I have zero experience with compiling graph-tool (or anything else) for windows, but the following part of your config.log stands out:
configure:17224: checking whether the Boost::Python library is available
configure:17254: g++ -c -Wall -ftemplate-depth-150 -Wno-deprecated -Wno-unknown-pragmas -O99 -fvisibility=default -fvisibility-inlines-hidden -Wno-unknown-pragmas -Ic:\python27\include conftest.cpp >&5
conftest.cpp:32:36: fatal error: boost/python/module.hpp: No such file or directory
compilation terminated.
Note how the boost path you passed is not being used! Try to pass CXXFLAGS="-IC:\boost\include" to configure as well.
May be something like this would help:
./configure --prefix=/usr/
for windows path is different, try it yourself.
Um, I'm stumped and really stuck (+_+) here after googling many sites. I'm using mingw32-gcc.exe from Dev-c++ compiler and currently following instructions from this site.
Every time I try here's the result:
C:\Python26>python c:\python26\python-mcrypt-1.1\setup.py install
running install
running build
running build_ext
error: don't know how to compile C/C++ code on platform 'nt' with 'mingw32-gcc.exe' compiler
I've edited the distuils.cfg file in my c:\python26\lib\distuils\distuils.cfg with this parameter
[build]
compiler = mingw32-gcc.exe
Any ideas would be appreciated!
You installed python outside of a compilation environment valids one include cygwin or mingw32 (wich is used by Dev-C++).
To use the command-line mode, you need to find the your compiler installation and find bat script which launch the shell with the proper parameters (This is needed for bith cygwin and mingw).
The alternative is to use Microsft solution for that problem.
I am loading a dll in python using following code:
if os.path.exists(dll_path):
my_dll = ctypes.cdll.LoadLibrary(dll_path)
But I am continuously getting the following error
WindowsError: [Error 126] The specified module could not be found
dll is present at the specified path, but I didn't understand why I'm getting the error.
Note that even if the DLL is in your path. If that DLL relies on other DLLs that are NOT in your path, you can get the same error. Windows could not find a dependency in this case. Windows is not real good at telling you what it could not find, only that it did not find something. It is up to you to figure that out. The Windows dll search path can be found here:
http://msdn.microsoft.com/en-us/library/7d83bc18.aspx
In my case, being sure all needed dlls were in the same directory and doing a os.chdir() to that directory solved the problem.
When I see things like this - it is usually because there are backslashes in the path which get converted.
For example - the following will fail - because \t in the string is converted to TAB character.
>>> import ctypes
>>> ctypes.windll.LoadLibrary("c:\tools\depends\depends.dll")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\tools\python271\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "c:\tools\python271\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
There are 3 solutions (if that is the problem)
a) Use double slashes...
>>> import ctypes
>>> ctypes.windll.LoadLibrary("c:\\tools\\depends\\depends.dll")
b) use forward slashes
>>> import ctypes
>>> ctypes.windll.LoadLibrary("c:/tools/depends/depends.dll")
c) use RAW strings (prefacing the string with r
>>> import ctypes
>>> ctypes.windll.LoadLibrary(r"c:\tools\depends\depends.dll")
While this third one works - I have gotten the impression from time to time that it is not considered 'correct' because RAW strings were meant for regular expressions. I have been using it for paths on Windows in Python for years without problem :) )
On the off chance anyone else ever runs into this extremely specific issue..
Something inside PyTorch breaks DLL loading. Once you run import torch, any further DLL loads will fail. So if you're using PyTorch and loading your own DLLs you'll have to rearrange your code to import all DLLs first. Confirmed w/ PyTorch 1.5.0 on Python 3.7
I met the same problem in Win10 32bit OS. I resolved the problem by changing the DLL from debug to release version.
I think it is because the debug version DLL depends on other DLL, and the release version did not.
If you are using GCC to compile it for Windows, it's possible that the error is because dependent libraries can't be found.
Using the -static flag if linking with GCC might fix that.
Also this could be that you have forgotten to set your working directory in eclipse to be the correct local for the application to run in.
In Windows, it's possible. You will need to install: Visual C++ Redistributable for Visual Studio 2015. I had the same problem and I installed both version (Windows x86 and Windows x64). Apparently both are necessary to make it work.
Tried to specify dll path in different ways (proposed by #markm), but nothing has worked for me.
Fixed the problem by copying dll into script folder. It's not a good solution, but ok for my purposes.
for me install Microsoft Visual C++ 2015 Redistributable Update 3 from https://www.microsoft.com/en-us/download/details.aspx?id=53587 solved it.
if you come across this error when you try running PyTorch related libraries you may have to consider installing PyTorch with CPU only version i.e. if you don't have Nvidia GPU in your system.
Pytorch with CUDA worked in Nvidia installed systems but not in others.
There is a promising answer at Problem updating bokeh: [WinError 126] The specified module could not be found.
It hints at https://github.com/conda/conda/issues/9313.
There, you find:
It's a library load issue. More details at
github.com/conda/conda/issues/8836 You probably have a broken conda
right now. You can use a standalone conda from
repo.anaconda.com/pkgs/misc/conda-execs to repair it:
standalone-conda.exe update -p C:\ProgramData\Anaconda3
conda-package-handling You should get version 1.6.0, and the problems
should go away.
Thus, it might simply be a conda issue. Reinstalling standalone conda might repair the error. Please comment whoever can confirm this.
problem solved for me.
I changed version from pytorch=1.5.1 to pytorch=1.4 and typed the below command in anaconda prompt window
conda install pytorch==1.4.0 torchvision==0.5.0 -c pytorch
NestedCaveats solution worked for me.
Imported my .dll files before importing torch and gpytorch, and all went smoothly.
So I just want to add that its not just importing pytorch but I can confirm that torch and gpytorch have this issue as well. I'd assume it covers any other torch-related libraries.
This is probably because a runtime dependency of one of the DLLs was not found on your system. I think that the expected Microsoft Visual C runtime DLL is missing from your system.
Install this:
https://www.microsoft.com/en-US/download/details.aspx?id=40784
I fixed this issue by installing VC redistributable for Visual Studio 2012 and the up-to-date Visual Studio versions. After reboot, the problem has gone.