Skip to content

Compiled executable using PackageCompiler Β #22

@Wieke

Description

@Wieke

Hi everyone

So I ran into an issue when using Octo with a compiled executable. Such a compiled executable doesn't like it when you try to load code dynamically during runtime and it can't use the functions loaded. This is a problem because Octo dynamically loads backend code when Repo.connect is called. But I found a little workaround, namely calling Octo.Backends.backend deliberately in the root of the compiled module. Here's an example based on the PackageCompiler example of an compiled executable:

module Test
using Octo.Adapters.SQLite
Octo.Backends.backend(Octo.Adapters.SQLite) # without this function call the compiled executable fails.

Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
	Repo.connect(adapter = Octo.Adapters.SQLite, dbfile = "test.sqlite")
	Repo.execute(Raw("""
	   CREATE TABLE IF NOT EXISTS Test (
	       ID integer not null primary key,
	       Name nvarchar(128) not null
	   )"""))
    return 0
end
end

I'm sharing this in case anybody else runs into this problem. (And so the devs of Octo know there's a small problem of course.)

Cheers,

Wieke

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions