I need help to call a Fortran shared library (DLL) from a QGIS python plugin.
For this purpose I created a simple fortran dll with the function to add two integers.
Also I create a simple python code that invokes the fortran dll to perform the addition.
This python code successfully got executed using python.exe in the Python installed path (and the Python.exe in the QGIS Bin directory)
But on trying to load this dll from QGIS > Plugin > Python console, with the below two lines,
from ctypes import *self.gtflib = cdll.LoadLibrary('fadd.dll')the following error is displayed:
Traceback (most recent call last): File "", line 1, in File "C:\PROGRA~2\QGISWI~1\apps\Python27\lib\ctypes__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "C:\PROGRA~2\QGISWI~1\apps\Python27\lib\ctypes__init__.py", line 365, in init self._handle = _dlopen(self._name, mode)WindowsError: [Error 126] The specified module could not be found
The same error happens in my actual plugin too.
I have the fadd.dll copied to the 'C:\PROGRA~2\QGISWI~1\bin'.
Is there anything specific needed in QGIS to load the fortran dll.Thanks in advance for any help.
The fortran source code:
integer function add2i(x, y) integer, intent(in) :: x, y add2i = x + yend function add2iThis is compiled with gfortan on windows to create fadd.dll.
The python code:
from ctypes import *libadd = cdll.LoadLibrary("./fadd.dll")method = libadd.add2i_x = c_int(47)y = c_int(11)print "x = %d, y = %d" % (x.value, y.value)result = method( byref(x), byref
)print "x = %d, y = %d, z = %d" % (x.value, y.value, result), and the python file to invoke the dll is attached.
أكثر...
For this purpose I created a simple fortran dll with the function to add two integers.
Also I create a simple python code that invokes the fortran dll to perform the addition.
This python code successfully got executed using python.exe in the Python installed path (and the Python.exe in the QGIS Bin directory)
But on trying to load this dll from QGIS > Plugin > Python console, with the below two lines,
from ctypes import *self.gtflib = cdll.LoadLibrary('fadd.dll')the following error is displayed:
Traceback (most recent call last): File "", line 1, in File "C:\PROGRA~2\QGISWI~1\apps\Python27\lib\ctypes__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "C:\PROGRA~2\QGISWI~1\apps\Python27\lib\ctypes__init__.py", line 365, in init self._handle = _dlopen(self._name, mode)WindowsError: [Error 126] The specified module could not be found
The same error happens in my actual plugin too.
I have the fadd.dll copied to the 'C:\PROGRA~2\QGISWI~1\bin'.
Is there anything specific needed in QGIS to load the fortran dll.Thanks in advance for any help.
The fortran source code:
integer function add2i(x, y) integer, intent(in) :: x, y add2i = x + yend function add2iThis is compiled with gfortan on windows to create fadd.dll.
The python code:
from ctypes import *libadd = cdll.LoadLibrary("./fadd.dll")method = libadd.add2i_x = c_int(47)y = c_int(11)print "x = %d, y = %d" % (x.value, y.value)result = method( byref(x), byref
أكثر...