$ zig version
0.5.0+1baaf9a50
$ uname -a
Linux chaosknight 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
I tried my hand at making a natively implemented function for Erlang/Elixir and ran into the following issue when using build-lib:
$ zig build-lib --disable-gen-h --library c -I /usr/lib/erlang/usr/include/ --name zig_hello_world -dynamic -fPIC hello_world.zig
Build Dependencies...lld: error: relocation R_X86_64_PC32 cannot be used against symbol entry; recompile with -fPIC
>>> defined in ./zig_hello_world.o
>>> referenced by hello_world.zig:65 (/home/gonz/code/elixir/nif_sandbox/nif/hello_world.zig:65)
>>> ./zig_hello_world.o:(nif_init)
The code being compiled (as well as the automatically generated cimport.zig file) can be found here:
Environment info:
I tried my hand at making a natively implemented function for Erlang/Elixir and ran into the following issue when using
build-lib
:The code being compiled (as well as the automatically generated
cimport.zig
file) can be found here:https://gist.github.com/GoNZooo/973571ca3011834026bb539a28336650
Removing
extern
on line 64 fixes the issue but it's unclear to me why.