Inkognito

Inkognito

Need help configuring Zigler with link_lib

Hi,

I am trying to write a elixir client for

https://github.com/sst/opentui.git

What I am attempting to do is fetch the zig code, compile it in priv and then use it via Zigler.

I cant seem to get Zigler to find the header and/or the link_lib

I am using a x86_64 machine and running in WSL2

error:

\*\* (CompileError) lib/jace/bridge.ex:5: error: C import failed

pub const cc = @cImport(@cInclude(“opentui.h”)).createRenderer;
^\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~
referenced by:
streamModule__anon_24197: .elixir_ls/build/test/lib/zigler/priv/beam/sema.zig:231:45
main: .elixir_ls/build/test/lib/zigler/priv/beam/sema.zig:284:21
4 reference(s) hidden; use ‘-freference-trace=6’ to see all references
/home/archon/.cache/zig/o/4fd94b536b9f26726f3d4aaeabed04ae/cimport.h:1:10: error: ‘opentui.h’ file not found
#include <opentui.h>

Is my approach correct ?
Am I missing something stupid?
Any feedback and/guidance is welcome.

Most Liked

joelpaulkoch

joelpaulkoch

Hey, according to the docs you should specify a relative path: host/... without the leading /. Hope this helps.

joelpaulkoch

joelpaulkoch

The error message that you showed comes from elixir_ls, but is the actual compilation failing with the same error?

Also on the screenshot I can see that the zig code in the _build directory, but how did it get there? Is it in the priv directory of your project too?

Last Post!

Inkognito

Inkognito

Hi @joelpaulkoch

Thanks for this, I had a mix.task which was updating the build folder, I have changed it to put it in the correct priv.

   @lib  {:priv, "zig/lib/x86_64-linux/libopentui.so"}
   @header  {:priv, "include/"}
  
   use Zig,otp_app: :jace,
    c: [link_lib: @lib,include_dirs: @header,library_dirs: @lib],
    resources: [:RendererResource,
                :OptimizedBufferResource,
                :TextBufferResource],
    nifs: [...]

now does not throw errors in IDE and , can confirm it is picking up the headers, and lib correctly.

however when i run the app it’s not able to find the .so file

20:12:06.886 [error] loading module Elixir.Jace.Bridge {:load_failed, ~c"Failed to load NIF library /home/archon/work/jace/_build/dev/lib/jace/priv/lib/Elixir.Jace.Bridge: 'libopentui.so: cannot open shared object file: No such file or directory'"}

I am re-reading the docs and trying again,

thanks again !!

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement