Compiling a library from a custom module

Hi there!

I hope this is the right place to ask this question.
I wrote a custom module “MOD”, and eventually I want to compile this module and its functions into a DLL, which functions I can call from a LabView program.

For the moment, I develop on Ubuntu 18.04. As a test, I tried to generate a *.so file. I tested the module extensively with Julia 1.2, but I also run it with Julia 1.5 without any problems.

Now I saw that PackageCompiler can do what I want, and it even provides a description how to compile a library (sysimage) without PackageCompiler.

However, when I run

using PackageCompiler
activate .
using .MOD
create_sysimage(:MOD; sysimage_path="", incremental=false, precompile_execution_file="build-tools/precompile-script.jl")

I get the error message: ERROR: package(s) MOD not in project.

Off course my module “MOD” is not handled by the package manager, but it is a module defined in the file src/MOD.jl which looks a bit like this:

module MOD

using DataFrames;
using LinearAlgebra: pinv
using DSP: conv
# ...

# Include functions
# ...

end # module

What can I do that PackageCompiler recognizes my custom module?

Alternatively I tried to compile the library without PackageCompiler. In a first step to create the object file:
julia --startup-file=no --output-o Sysimage.o -J"/julia/dir/lib/julia/" custom_sysimage.jl

where the script custom_sysimage.jl looks like


using .MOD

using DataFrames
using CSV
data = DataFrame(CSV.File("dummy.csv"))


However, with this approach, I get the error:

ERROR: LoadError: could not load library "" Kann die Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden
(english: Cannot open the shared object file: file or directory not found)

However, when I start a julia session and do

using .MOD

using DataFrames
using CSV
data = DataFrame(CSV.File("dummy.csv"))

It runs without any error message.

All these examples were performed with Julia 1.5.

Can anybody guide me what is going wrong and how I can manage to compile these functions into a .*so and finally into a DLL object? Currently I have no clue where I should start.

Furthermore, if I have some mistakes in my design, and it should be designed in some other way in order to reach my goal, please let me know!

I tried to include

using Pkg
pkg"activate ."

in the custom_sysimage file, because I became aware that I worked in the @v1.5 environment, and not in the local environment (although this should not change much, because I have all necessary packages installed in the @v1.5 environment also). However, these lines generate the following error:

ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
- Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.

That is strange. using CSV and using DataFrames work, but using Pkg does not work…

As a second attempt, I omitted the flag “–startup-file=no” (because I didn’t really know why it should be important to not use the startup file for the system image generation), but I still get the error, that “” could not be found. This library belongs to the FFTW package, which is a dependency of the DSP package.

However, when I simply run the command without the --output-o flag, everything runs without an error (however, no Sysimage is created off course…)

1 Like

Just to let people with the same problem know: It is really a mess and a never ending storry, to get this working in the way I want to…

I am using now ZeroMQ to communicate and transfer data between Julia and LabView.