lua-users home
lua-l archive

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


On Mon, Mar 11, 2013 at 9:01 AM, Jerome Vuarand
<jerome.vuarand@gmail.com> wrote:
> 2013/3/10 Choonster TheMage <choonster.2010@gmail.com>:
>> I'm writing a library that depends on lua-zlib[1], but I'm having a
>> hard time compiling it on Windows. I've tried doing it Visual Studio
>> 2012, but I really have no idea what I'm doing.
>>
>> When I try to compile it in VS, I get a bunch of linker errors telling
>> me that symbols can't be found (these are things defined in lua.h,
>> lauxlib.h or zlib.h). VS can find the header files that define these
>> symbols without issue, but it seems the linker can't find the files it
>> needs.
>>
>> Can anyone tell me how to compile lua-zlib (and C libraries in
>> general) on Windows? I'm open to using VS2012, Cygwin, MinGW or pretty
>> much anything else.
>
> To be able to use the Lua and zlib DLLs, the compiler need the
> headers, and the (VS) linker need import libraries (it's a kind of
> static libraries that don't contain much code but will instead load
> the corresponding DLL at runtime). You should find these libraries
> either in precompiled packages you download or they are generated by
> the compiler if you built Lua and zlib yourself. You need to specify
> lua51.lib and zlib1.lib (or whatever their name in your system) to the
> linker in the link property pages in Visual Studio. Note that you may
> have to specify the file names (without path) and the directory they
> are in in different properties (though I think specifying absolute
> paths in the library list is OK).
>
> The same is true for other compilers and linkers, with subtle
> differences. MinGW for example can use the DLL files directly without
> import libraries, but you will need to point at these DLLs in the
> linker options nonetheless.
>

Thanks, I was able to compile it by adding the directories with the
.lib files to the Linker > General > Additional Library Directories
property and adding the file names to the Linker > Input > Additional
Dependencies property.

Unfortunately when I try to require it from LuaJIT, I get this error:

------------------------------------------------------------------------------
error loading module 'lua-zlib' from file
'C:\Lua\LuaJIT_2.0\clibs\lua-zlib.dll':
        The specified procedure could not be found.

stack traceback:
        [C]: at 0x58944420
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: at 0x011f1d80
------------------------------------------------------------------------------

I get the same error with question marks instead of hex numbers if I
require it from Lua 5.1.5.

What am I doing wrong?