Hermanverschooten
Undefined symbol when using zigler and C file
This my first time using zig and zigler.
I am trying to use the embedded library for wireguard.
I have in the same folder, wireguard.h, wireguard.c and wireguard.ex.
The Wireguard module has
defmodule Wireguard do
use Zig,
otp_ap: :wg_man,
c_src: [{"wireguard.c", ["-Wall"]}],
include_dir: "."
~Z"""
const std = @import("std");
const crypto = std.crypto;
const log = std.log.scoped(.wireguard);
const wireguard = @cImport({
@cInclude("wireguard.h");
});
pub fn list_devices() void {
var deviceNames: [*c]u8 = null;
deviceNames = wireguard.wg_list_device_names() orelse null;
defer std.c.free(@ptrCast(?*anyopaque, deviceNames));
if (deviceNames == null) {
log.err("Unable to get device names", .{});
return;
}
}
"""
When I try to mix compile, I get the following error:
== Compilation error in file lib/wireguard/wireguard.ex ==
** (MatchError) no match of right hand side value: ["error: ld.lld: undefined symbol: wg_list_device_names\n note: referenced by .Elixir.Wireguard.zig:13 (/home/herman/Projects/wg_man/lib/wireguard/.Elixir.Wireguard.zig:13)\n note: /home/herman/.cache/zig/o/f3cd82336c77b73ffaead67d9007ba46/sema.o:(.Elixir.Wireguard.list_devices)"]
(zigler 0.10.2) lib/zig/compile_error.ex:11: Zig.CompileError.to_error/2
(zigler 0.10.2) lib/zig/sema.ex:88: Zig.Sema.run_sema!/3
(zigler 0.10.2) lib/zig/compiler.ex:76: Zig.Compiler.compile/4
(zigler 0.10.2) expanding macro: Zig.Compiler.__before_compile__/1
lib/wireguard/wireguard.ex:1: Wireguard (module)
This function is defined in wireguard.c, so why is it not being found?
If I remove the body from the zig function it compiles and when I look at the exported functions in the generated Elixir.Wireguard.so I do find all the functions there.
I am probably missing something, but I have no clue where to start looking.
Marked As Solved
ityonemo
@Hermanverschooten should be fixed in 0.10.3, feel free to reopen bug report if it doesn’t work.
5
Also Liked
ityonemo
this is a bug in zigler. I think i know how to fix it, thanks for the report.
1
Popular in Questions
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”:
14:57:30.512 [warn] ...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Other popular topics
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New







