0

I'm using libwebsockets and lwsws to run an HTTP server and a Web Socket server, but it requires to write the web socket protocol code in a specific .dll plugin (HTTP provided by lib). Everything is developped with VS2015 (or VS2008).

The code to initialize and run this server is wrapped in a C++ object that I use in my executable project and this leads me to this problem:

I want to be able to call functions, and use variables, from the executable project API in my .dll plugin without ending-up with the code being compiled and put in that .dll; how can I do that?

A. Gille
  • 912
  • 6
  • 23
  • If I understand correctly, this works in pretty much the same way that you'd do it the other way around: you have to export the functions from the executable and import them into the DLL. For example, you could use `__declspec(dllexport)` and `__declspec(dllimport)`, or a definitions file. Exporting from an application to a DLL is a little unusual, but I gather it works perfectly well. – Harry Johnston Jun 02 '16 at 01:44
  • Exporting symbols from executable and import them in the dll sounds logic, but how can I deal with the code I don't want to be put in **.dll** after compilation? The other point is, when creating my VS2015 project, I think I would have to include header files, but I'm afraid that I would have to include c code files too, and this will compile and put extra code in my dll, which is not what I want... I'm I right? Are header files enough when compiling the plugin dll only? – A. Gille Jun 02 '16 at 08:21
  • 1
    It's the same as linking to a DLL. Typically, you just include the headers. – Harry Johnston Jun 02 '16 at 21:04
  • That is great news, because I was really doubting about this and documentation is quiet hard to find in that kind of tricky case. I'll try this and I will come back to you if I succeed. Thanks! – A. Gille Jun 03 '16 at 08:49

0 Answers0