1

Today I spend on trying building OpenSSL on Windows with the LuaSec binding library to use it from Lua on Windows. (using MinGW / GCC, not MS compilers)

Lua uses its own paths searching facilities to locate the luasec binding library, but luasec just tries to open the openssl libraries in place. This means that the luasec library is neatly tucked away in the Lua package eco system, but the openssl ones need to be located next to the process executable, which is lua.exe in this case. What I dislike most is that the lua executable is in the system path, but now also the openssl ones are...

So the question; when I build the LuaSec binding library, it links against both the Lua libraries and the openssl ones. Now I would like to statically link the openssl libraries into it. But not the lua libraries.

The result would be a single luasec dll (which includes the openssl code) that could be dynamically loaded by Lua.

Is this even possible? If so, any pointers on how to achieve this?

Thx!

PS. I saw some packaging tools, but they pack the entire application into a single executable, in this case I would like the result to be a dll.

Tieske
  • 363
  • 3
  • 10
  • You're asking if it's possible to statically link code into a library? Of course it is. – Mud Aug 22 '14 at 22:38
  • I think you should use `nt.mak` rather than `ntdll.mak` makefile. – jww Aug 23 '14 at 01:33
  • @mud; I can do static, I can do dynamic, but I want only the OpenSSL lib linked statically into the binding dll, but not include the Lua dlls. – Tieske Aug 23 '14 at 07:09
  • @jww; nothing to do with the runtime. And please elaborate on `nt.mak`? Isn't that for the MS toolchains? this is for gcc / MinGW / MSYS – Tieske Aug 23 '14 at 07:10
  • @Tieske "static" vs "dynamic" binding of libraries is not like some global choice you make for an application. You make that choice per library. If you want OpenSSL statically bound to luasec, then include the source and make it statically bound. If you want Lua dynamically bound to luasec, then leave it as is. I don't understand where the point of confusion is. Are you just unfamiliar with how linking works? Is the question about MAKE syntax, or some part of the compiler toolchain? It doesn't seem to have anything to do with Lua, specifically. – Mud Aug 23 '14 at 07:28
  • @mud; you're probably right, and I should have formulated my question more carfully. 'including source' is out of my skill set for now. OpenSSL can be built to deliver static or dynamic libraries. So if I generate static ones, Can I then, when linking LuaSec together, tell the linker to use the dynamic Lua libraries and the static OpenSSL ones? – Tieske Aug 24 '14 at 08:11
  • @Tieske Yes, you can do exactly that. In fact, even with a dynamic library, usually there's a stub library that you statically link which takes care of loading the dynamic library. You can just swap that for the full static library rather than the stub. – Mud Aug 24 '14 at 17:05
  • @mud thx. Any links to a how to or a more detailed explanation on how to do this? would be most welcome – Tieske Aug 25 '14 at 05:03

0 Answers0