Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled executable using PackageCompiler #22

Open
Wieke opened this issue Dec 21, 2019 · 1 comment
Open

Compiled executable using PackageCompiler #22

Wieke opened this issue Dec 21, 2019 · 1 comment

Comments

@Wieke
Copy link

Wieke commented Dec 21, 2019

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

@wookay
Copy link
Owner

wookay commented Dec 21, 2019

thanks for the sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants