Most likely you're missing one of the dependency dll's (or Julia can't find
it). Check in Dependency Walker and/or cygcheck to see which it is -
probably the libgfortran dll. Also note that since Julia itself is built
using mingw-w64 compilers, trying to load libraries built by the standard
cygwin compilers may be unreliable. You can install the cross-compiler
package mingw64-x86_64-gcc-fortran from Cygwin's setup.exe, then invoke
x86_64-w64-mingw32-gfortran rather than just gfortran and you'll get a dll
that is more likely to be compatible with Julia.
On Wednesday, June 22, 2016 at 5:45:49 PM UTC-4, Kaela Martin wrote:
>
> I'm trying to get Julia to run a Fortran file on Windows 10, and Julia
> says that it can't open the library. Libdl.dlopen also fails to open the
> file. I've tried adding the current path to LOAD_PATH but still get the
> same error.
>
> For a test case, I'm running the following module:
>
> module hello_module
> use iso_c_binding
> implicit none
> contains
>
> subroutine hello() bind(C,name="hello")
> !DEC$ ATTRIBUTES DLLEXPORT :: hello
> write(*,'(A)') "Hello World!!!"
> end subroutine hello
>
> end module hello_module
>
> I'm compiling it in Cygwin64 (I'm on a 64bit Windows 10 machine) using
> gfortran with:
>
> gfortran -shared -o2 -fPIC Hello.f90 -o HelloWorld.dll
>
> I get a warning that -fPIC is ignored, but the file compiles and creates
> HelloWorld.dll
>
> In Julia, I call the library using
>
> ccall((:hello,"HelloWorld.dll"),Void,())
>
> which results in:
>
> ERROR: could not load library "HelloWorld.dll"
> The specified module could not be found.
>
> in dlopen at libdl.jl:36 (repeats 2 times)
> in dlopen at deprecated.jl:32
>
> Just trying to open the module using Libdl.dlopen("HelloWorld.dll") gives
> the same error.
>
> Note that I moved the .dll file to a new location after compiling it since
> the goal is to put the code in a single folder that other users can put on
> their windows machines and run.
>
> How do I get Julia to open and run the code?
>
> Thanks,
> Kaela
>