Welcome to Julia! You probably shouldn't necromance such an old thread, instead make a new one and link to the old ones you researched.
Anyway, in the old thread, I linked to a blog post of mine on this topic (I just saw that its formatting was all messed up: now fixed): http://maurow.bitbucket.org/notes/calling_fortran_from_python.html http://maurow.bitbucket.org/notes/calling_fortran_from_c.html The post outlines the steps I did to make it work and how you can use the iso_c_binding module which prevents name-mangling and provides C-datatypes. Maybe this helps. On Mon, 2016-01-18 at 20:36, pokerhontas...@googlemail.com wrote: > Hi, > > first of all, I am new to Julia (and Fortran). I tried to follow OP's > example and call Fortran from Julia. First, I was using the Intel Fortran > compiler and tried to compile the following .f90 file (saved as f90tojl.f90) > > module m > contains > integer function five() > five = 5 > end function five > end module m > > as a shared library, by entering the following in the command line: > > ifort f90tojl.f90 -O2 -dll -fPIC -o ifortlib.dll > > the compiler ignores -fPIC since that's an unknown option apparently but > two files are created, one object file and the dll. I then try to call the > function from Julia and that's where the trouble starts. > > The suggested command in this thread doesn't work because I guess the Intel > compiler has different name mangling than the gfortran compiler. So I tried > to find the name of my function, wikipedia suggests m_MP_five_ for ifort, > so I tried > > julia: ccall( (:m_MP_five, "ifortlib.dll"), Int, () ) > > LoadError: ccall: could not find function m_MP_five in library ifortlib.dll > > > So my guess is that I am not using the correct name mangling. I couldn't find > anything online so I tried to view the function name via the object manager > in visual studio and an external dll viewer program. > In visual studio I got a meaningless error the external viewer just didn't do > anything (although it worked for other dll files). When I type > > julia: Libdl.dlopen("ifortlib.dll") > Ptr{Void} @0x000000002a9d8fa0 > > fwiw. At this point I got so pissed that I decided to install the gfortran > compiler and just follow this thread step by step. So in the cmd window, I > type: > > gfortran -shared -O2 f90tojl.f90 -fPIC -o gfortlib.dll > > (I get a warning that -fPIC is ignored, as written previously in this > thread). I use the dll viewer to determine the name of the function, its > __m_MOD_five indeed. Then > > julia: ccall( (:__m_MOD_five, "gfortlib.dll"), Int, () ) > > LoadError: error compiling anonymous: could not load library "gfortlib.dll" > The specified module could not be found. > > > And > > julia: Libdl.dlopen("gfortlib.dll") > LoadError: could not load library "gfortlib.dll" > The specified module could not be found. > > > And I have no clue what to do now.