Symbol not found when importing Fortran library within custom Package

I’m importing compiled Fortran code as a shared library within a custom package I have created. However, when I call a Fortran function from my module within Python using JuliaCall (GitHub - cjdoris/PythonCall.jl: Python and Julia in harmony.) and Ccall I get a symbol not found error. My module looks like this:

module Simulation
    using Libdl
    Libdl.dlopen("FortranFunctions", RTLD_LAZY | RTLD_DEEPBIND | RTLD_GLOBAL)
    include("julia_code_that_calls_fortran.jl")

is this the proper way to import a shared library within a module? I’m calling it in Python using JuliaCall via:

 from juliacall import Main as jl
      jl.seval("using Simulation")
     jl.Simulation.*ccall function within julia_code_that_calls_fortran.jl* (Pseudocode)

I imagine the dlopen has to be inside __init__() Modules · The Julia Language. Another way would be to build your fortran library with GitHub - JuliaPackaging/BinaryBuilder.jl: Binary Dependency Builder for Julia and add it to GitHub - JuliaPackaging/Yggdrasil: Collection of builder repositories for BinaryBuilder.jl

Thanks, that worked! I’ve looked at the docs and can’t really figure out why that worked however……do you have a better explanation?

Basically, what you had written would try to run at precompile time not at actual runtime when the user wrote using MyPackage . __init__() serves the exact purpose you had, which is to run something when the user calls using MyPackage. So it could have the opening of the shared library, some initialization steps that could be needed etc.