iot-edge-v1 icon indicating copy to clipboard operation
iot-edge-v1 copied to clipboard

using nanomsg as a static library

Open kiranpradeep opened this issue 8 years ago • 3 comments

I tried building and using nanomsg as a static library. It worked well when I only had out of proc modules. But if I try to use nanomsg as static library in in-proc modules, then in-proc modules are not able to communicate with each other(Broker_Publish).

kiranpradeep avatar Dec 14 '17 15:12 kiranpradeep

I'm assuming this was is a Windows build....

Nanomsg (as a library) has some global static variables which it uses to keep track of handles, open ports, etc. The Windows build will create a separate instance of these static variables in each DLL that statically links to the nanomsg library, and they don't link to each other, so the modules use one set of globals, and the core gateway uses a different set, and nanomsg can't resolve the two. Putting nanomsg into its own DLL creates one instance of the global variables, and the modules and gateway core all use it.

That's why we build nanomsg as a DLL in our project. It's a side-effect of using dynamically loaded DLLs for modules.

darobs avatar Dec 14 '17 21:12 darobs

@darobs Thanks for the reply. I am on an Ubuntu 16.04 LTS, but feels what you said still holds true for in-proc modules in Linux as well. So can I assume that iot-edge in-proc modules cannot use nanomsg as a static library on Windows/Linux platforms?

kiranpradeep avatar Dec 15 '17 02:12 kiranpradeep

Interesting. I didn't know this was a problem for Linux, but it's been quite a while since I've attempted it. Yes, I would say the inproc modules cannot use nanomsg as a static library on any platform.

darobs avatar Dec 15 '17 18:12 darobs