How can I open erl_interface (Erlang C library) via DLL?

I have been working non-stop for the past three days on a fully managed Erlang frontend. At this point, I decided that there just needs to be an easier way. I have just over 3000 lines and it is not in a compiled state yet. To be honest, I'm getting lost in my own code.

So, I then remembered that Erlang has a C library called erl_interface. Unfortunately, it only appears as a .LIB file that cannot be used with P / Invoke. I am now exploring ways to publish a static library via a DLL.

I would like to stay away from Visual C ++, mainly because I am not a C / C ++ programmer by nature and I find it difficult to customize it. TinyC is my compiler of choice when working with anything in C.

How can i do this?

I know I can link erl_interface to the DLL, but how can I expose the functions? Should I essentially wrap each of them in my own export? This probably won't be a problem as I could write a script to generate code from a header file. But is there an easier way that I just don't know about?

Also, it is not recommended to use OTP.NET. It's a nice library, but I'm looking to use this large project, so I would like to keep it at home.

+2


source to share


2 answers


So your problem is converting a static library to a dynamic one.

The least cost solution would be to write a thin shim file in 'C' that just delegates files to .lib, for example.

ReturnType my_method1(args...) {
  return real_method1(args...);
}
...

      



and build the DLL from this and the static lib.

Afterthought - there is another approach you could take - which creates a .lib into a C ++ / CLI assembly and makes the transition / completion in that. This is what C ++ / CLi exists after all.

+1


source


If you need help interacting with Erlang with C, have a look at the "EPAPI" (Erlang API) link text . You can of course view the source code as it is hosted on Google Code. The DEBIAN repository is also available.



0


source







All Articles