lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 6/12/2007, at 8:38 AM, Stefan Sandberg wrote:

Right, sometimes it works, sometimes it doesn't, but it -should- imo not work, it's incorrect sortof..

Using two different Luas definitely seems incorrect to me. I'd feel pretty bad if I encouraged anybody to do that because it worked by luck in one situation for me. As I said, I now have ONE Lua, and it's soooo much better :-)!

Did you link stuff to symbols exported from your exe? A lot of people on #lua have asked for that lately, so it would be cool for reference if you could spit out how to do that.

Ummm, the trouble is, I don't know what the trick was. It seemed like it wasn't working, and then I thought I changed nothing, and then it seemed to be working. Also, I don't quite remember, and digging around in svn hasn't come up with the answer yet.

But anyway, on Visual C++.net 2003 standard edition, with the compiler "upgraded" to the free optimizing one they made available on the web about, what, four years ago (so pretty old tools).

I think all I needed to do was make sure that you define LUA_BUILD_AS_DLL when you're compiling Lua, and it'll set itself up to export the symbols (either from a DLL, or from an exe). However, it might be that to get this to work, I had to include the Lua source files in the build of the executable, not build Lua into a static library, and then link that it. I have a vague memory of there being some kind of problem with that - but svn doesn't teach me anything.

Sorry that's not very useful. If anyone's really interested, I'll have another dig around and see if I can make that work again.

cheers,
Geoff


Geoff Leyland wrote:
On 6/12/2007, at 7:30 AM, John Dunn wrote:

Is it possible to have my app statically link to lua but also allow for
DLL based packages to work correctly? I'd like to add support for
sockets in my library using the luasockets package. I've built the
sockets library so it links to a static version of the lua library and it appears to work.I know that by having the app and package statically link they each end up with their own copy of lua - Is this a really bad
thing?

I used to statically link Lua into one of my apps on windows. At first I statically linked all the libraries (lfs, luazip) in too into one executable. That worked pretty well, and there was only one file to "install". Then I statically linked Lua, exported all the Lua symbols from the app, and dynamically linked lfs and luazip to that. I used the multi-threaded DLL run-time and that worked fine.
Now I do dynamically link Lua, and that works too.

I have seen luasockets crash a few times - could the multiple copies of lualib cause this sort of thing? In general, is statically linking a bad
idea when using .dll based packages?

I accidentally used a luazip from a lua.dll, but the luazip was linked to a lua5.1.dll - and it managed to find one of those on the path. It actually worked, but I really don't think it's a good idea. (especially when things mysteriously didn't work on machines where luazip couldn't find a lua5.1.dll).

cheers,
Geoff