Erl_nif.h file NIfs on Windows10

Please tell me.
I want to run Nifs on Windows10.
When compiling with the MiGW version of GCC, I got the following error:
What should I do now?

C:\MinGW\mingw32\bin>gcc foo.c
gcc foo.c
foo.c:1:21: fatal error: erl_nif.h: No such file or directory
compilation terminated.

Version of GCC is following.
gcc version 5.3.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)

Version of Elixir is 1.9.4 .

Do you have the C:\MinGW\mingw32\include directory?

Thank you for reply.

Yes, there is the include folder.
However, erl_nif.h did not exist.
Should I find erl_nif.h and put it in the include folder?

No, not really, was just checking.

You should have erl_nif.h in your Erlang installation directory. Is it there?

Erlang OTP21 installed with Elixir did not have erl_nif.h.
However, Erlang OTP22 installed independently included erl_nif.h.


I’m not an expert in Erlang’s version differences, sadly.

But why don’t you try with 22.x and see if it solves your problem?

Thank you. I will try.

After copying the header file in the Erlang include into the current directory of Elixir, the compilation was successful.
However, loading with Elixir will result in an error. Looking at the explanation of Erlang, it is said that it compiles with cl.exe, so it may not work with MinGW. I will consider further.

Thank you.

In full honesty, building stuff on Windows in general is harder. You will have to tinker a lot by yourself.

Sorry I could not help further. I hope you solve your problem.

1 Like