problem compiling luasocket for lua 5.2 for VS2012

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

problem compiling luasocket for lua 5.2 for VS2012

Black, James A.

Hello,

  Luasocket compiled fine on linux, using lua 5.2.2, but when I try to do it on Windows, for VS2012 I run into errors.

 

I get unresolved errors such as:

   Creating library socket.lib and object socket.exp

mime.o : error LNK2019: unresolved external symbol _luaL_prepbuffsize referenced in function _mime_global_wrp

buffer.obj : error LNK2001: unresolved external symbol _luaL_prepbuffsize

buffer.obj : error LNK2019: unresolved external symbol _lua_tonumberx referenced in function _buffer_meth_receive

options.obj : error LNK2001: unresolved external symbol _lua_tonumberx

select.obj : error LNK2001: unresolved external symbol _lua_tonumberx

except.obj : error LNK2019: unresolved external symbol _lua_pcallk referenced in function _finalize

inet.obj : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _inet_global_getaddrinfo

tcp.obj : error LNK2001: unresolved external symbol __imp__getaddrinfo@16

inet.obj : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function _inet_global_getaddrinfo

tcp.obj : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4

inet.obj : error LNK2019: unresolved external symbol __imp__getnameinfo@28 referenced in function _inet_global_getaddrinfo

inet.obj : error LNK2019: unresolved external symbol _inet_ntop@16 referenced in function _inet_meth_getpeername

udp.obj : error LNK2001: unresolved external symbol _inet_ntop@16

select.obj : error LNK2019: unresolved external symbol _lua_callk referenced in function _check_dirty

udp.obj : error LNK2019: unresolved external symbol __imp__inet_pton@12 referenced in function _meth_sendto

socket.dll : fatal error LNK1120: 9 unresolved externals

 

   Creating library mime.lib and object mime.exp

mime.o : error LNK2019: unresolved external symbol _luaL_prepbuffsize reference in function _mime_global_wrp

mime.dll : fatal error LNK1120: 1 unresolved externals

 

When I built lua 5.2 I used this build.bat:

cl /MD /O2 /W3 /c /DLUA_BUILD_AS_DLL /DLUA_COMPAT_MODULE *.c

del *.o

ren lua.obj lua.o

ren luac.obj luac.o

link /DLL /IMPLIB:lua5.2.lib /OUT:lua5.2.dll *.obj

link /OUT:lua.exe lua.o lua5.2.lib

lib /out:lua5.2-static.lib *.obj

ren lua.o lua.obj

ren luac.o luac.obj

link /OUT:luac.exe luac.obj lua5.2-static.lib

 

I use this build.bat for luasocket.  I got the source for luasocket from github, on the unstable branch:

set INCLUDE=%INCLUDE%;C:\Users\my\Downloads\lua-5.2.2\src

echo %INCLUDE%

set LIB=%LIB%;C:\Users\my\Downloads\lua-5.2.2\src

echo %LIB%

ren unix.c unix.c00

ren usocket.c usocket.c00

del *.o

cl /MD /O2 /W3 /c /nologo /DWIN32_LEAN_AND_MEAN /DLUA_COMPAT_MODULE *.c

ren mime.obj mime.o

link /DLL /OUT:socket.dll /base:0x67800000 /export:luaopen_socket_core mime.o *.obj msvcrt.lib lua5.2.lib wsock32.lib

link /DLL /OUT:mime.dll /base:0x67700000 /export:luaopen_mime_core mime.o msvcrt.lib lua5.2.lib

 

I am curious what I may have done wrong in compiling luasocket.

 

I am trying to embed lua in a C++ program.

 

Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

Luiz Henrique de Figueiredo
> buffer.obj : error LNK2019: unresolved external symbol _lua_tonumberx referenced in function _buffer_meth_receive

This means that you're not linking with Lua 5.2.

Reply | Threaded
Open this post in threaded view
|

RE: problem compiling luasocket for lua 5.2 for VS2012

Black, James A.
I closed my console window and reopened it, and now I have this, in part due to I may have been including lua5.1 and 5.2, through different attempts, so I changed my build.bat to this, so I set the environment variable differently:
set INCLUDE=C:\Users\jb9\Downloads\lua-5.2.2\src;%INCLUDE%
set C:\Users\jb9\Downloads\lua-5.2.2\src;LIB=%LIB%

   Creating library socket.lib and object socket.exp
inet.obj : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _inet_global_getaddrinfo
tcp.obj : error LNK2001: unresolved external symbol __imp__getaddrinfo@16
inet.obj : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function _inet_global_getaddrinfo
tcp.obj : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4
inet.obj : error LNK2019: unresolved external symbol __imp__getnameinfo@28 referenced in function _inet_global_getaddrinfo
inet.obj : error LNK2019: unresolved external symbol _inet_ntop@16 referenced in function _inet_meth_getpeername
udp.obj : error LNK2001: unresolved external symbol _inet_ntop@16
udp.obj : error LNK2019: unresolved external symbol __imp__inet_pton@12 referenced in function _meth_sendto
socket.dll : fatal error LNK1120: 5 unresolved externals

C:\Users\jb9\Downloads\luasocket\src>link /DLL /OUT:mime.dll /base:0x67700000 /export:luaopen_mime_core mime.o msvcrt.lib lua5.2.lib
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Luiz Henrique de Figueiredo
Sent: Thursday, May 02, 2013 9:58 AM
To: Lua mailing list
Subject: Re: problem compiling luasocket for lua 5.2 for VS2012

> buffer.obj : error LNK2019: unresolved external symbol _lua_tonumberx referenced in function _buffer_meth_receive

This means that you're not linking with Lua 5.2.


Reply | Threaded
Open this post in threaded view
|

RE: problem compiling luasocket for lua 5.2 for VS2012

Thomas Buergel
> set INCLUDE=C:\Users\jb9\Downloads\lua-5.2.2\src;%INCLUDE%
> set C:\Users\jb9\Downloads\lua-5.2.2\src;LIB=%LIB%

Didn't you mean:

set LIB=C:\Users\jb9\Downloads\lua-5.2.2\src; %LIB%

?


Reply | Threaded
Open this post in threaded view
|

RE: problem compiling luasocket for lua 5.2 for VS2012

Black, James A.
Thank you, that was a typo.

I have the same errors, but when I look in the c compilations I see this:
luasocket.c
c:\users\jb9\downloads\luasocket\src\luasocket.h(26) : fatal error C1189: #error :  Lua 5.2 requires LUA_COMPAT_MODULE defined for luaL_openlib

So I used this command to try to resolve that:
cl /MD /O2 /W3 /c /nologo /DLUA_COMPAT_MODULE /DWIN32_LEAN_AND_MEAN *.c

I still have the 5 unresolved externals for socket.lib

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Thomas Buergel
Sent: Thursday, May 02, 2013 11:01 AM
To: Lua mailing list
Subject: RE: problem compiling luasocket for lua 5.2 for VS2012

> set INCLUDE=C:\Users\jb9\Downloads\lua-5.2.2\src;%INCLUDE%
> set C:\Users\jb9\Downloads\lua-5.2.2\src;LIB=%LIB%

Didn't you mean:

set LIB=C:\Users\jb9\Downloads\lua-5.2.2\src; %LIB%

?



Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

Paul K
In reply to this post by Black, James A.
Hi James,

inet_ntop and inet_pton appear to be missing on Windows. I patched
luasocket for mingw, but it seems like they are not present for VS as
well. You can find the commit that adds this functionality to
luasocket here:
https://github.com/pkulchenko/luasocket/commit/5a58786a39bbef7ed4805821cc921f1d40f12068

For the getaddrinfo you may need to link against ws2_32.

You may want to check build-mingw.sh script I have in this branch
(https://github.com/pkulchenko/luasocket/commits/lua52-mingw), which
works for me on Windows.

Paul.

On Thu, May 2, 2013 at 7:50 AM, Black, James A. <[hidden email]> wrote:

> I closed my console window and reopened it, and now I have this, in part due to I may have been including lua5.1 and 5.2, through different attempts, so I changed my build.bat to this, so I set the environment variable differently:
> set INCLUDE=C:\Users\jb9\Downloads\lua-5.2.2\src;%INCLUDE%
> set C:\Users\jb9\Downloads\lua-5.2.2\src;LIB=%LIB%
>
>    Creating library socket.lib and object socket.exp
> inet.obj : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _inet_global_getaddrinfo
> tcp.obj : error LNK2001: unresolved external symbol __imp__getaddrinfo@16
> inet.obj : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function _inet_global_getaddrinfo
> tcp.obj : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4
> inet.obj : error LNK2019: unresolved external symbol __imp__getnameinfo@28 referenced in function _inet_global_getaddrinfo
> inet.obj : error LNK2019: unresolved external symbol _inet_ntop@16 referenced in function _inet_meth_getpeername
> udp.obj : error LNK2001: unresolved external symbol _inet_ntop@16
> udp.obj : error LNK2019: unresolved external symbol __imp__inet_pton@12 referenced in function _meth_sendto
> socket.dll : fatal error LNK1120: 5 unresolved externals
>
> C:\Users\jb9\Downloads\luasocket\src>link /DLL /OUT:mime.dll /base:0x67700000 /export:luaopen_mime_core mime.o msvcrt.lib lua5.2.lib
> Microsoft (R) Incremental Linker Version 11.00.50727.1
> Copyright (C) Microsoft Corporation.  All rights reserved.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Luiz Henrique de Figueiredo
> Sent: Thursday, May 02, 2013 9:58 AM
> To: Lua mailing list
> Subject: Re: problem compiling luasocket for lua 5.2 for VS2012
>
>> buffer.obj : error LNK2019: unresolved external symbol _lua_tonumberx referenced in function _buffer_meth_receive
>
> This means that you're not linking with Lua 5.2.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

joao lobato
Boy, the luasocket bazaar is a bit hectic.

On 02/05/2013, Paul K <[hidden email]> wrote:

> Hi James,
>
> inet_ntop and inet_pton appear to be missing on Windows. I patched
> luasocket for mingw, but it seems like they are not present for VS as
> well. You can find the commit that adds this functionality to
> luasocket here:
> https://github.com/pkulchenko/luasocket/commit/5a58786a39bbef7ed4805821cc921f1d40f12068
>
> For the getaddrinfo you may need to link against ws2_32.
>
> You may want to check build-mingw.sh script I have in this branch
> (https://github.com/pkulchenko/luasocket/commits/lua52-mingw), which
> works for me on Windows.
>
> Paul.
>
> On Thu, May 2, 2013 at 7:50 AM, Black, James A. <[hidden email]> wrote:
>> I closed my console window and reopened it, and now I have this, in part
>> due to I may have been including lua5.1 and 5.2, through different
>> attempts, so I changed my build.bat to this, so I set the environment
>> variable differently:
>> set INCLUDE=C:\Users\jb9\Downloads\lua-5.2.2\src;%INCLUDE%
>> set C:\Users\jb9\Downloads\lua-5.2.2\src;LIB=%LIB%
>>
>>    Creating library socket.lib and object socket.exp
>> inet.obj : error LNK2019: unresolved external symbol __imp__getaddrinfo@16
>> referenced in function _inet_global_getaddrinfo
>> tcp.obj : error LNK2001: unresolved external symbol __imp__getaddrinfo@16
>> inet.obj : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4
>> referenced in function _inet_global_getaddrinfo
>> tcp.obj : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4
>> inet.obj : error LNK2019: unresolved external symbol __imp__getnameinfo@28
>> referenced in function _inet_global_getaddrinfo
>> inet.obj : error LNK2019: unresolved external symbol _inet_ntop@16
>> referenced in function _inet_meth_getpeername
>> udp.obj : error LNK2001: unresolved external symbol _inet_ntop@16
>> udp.obj : error LNK2019: unresolved external symbol __imp__inet_pton@12
>> referenced in function _meth_sendto
>> socket.dll : fatal error LNK1120: 5 unresolved externals
>>
>> C:\Users\jb9\Downloads\luasocket\src>link /DLL /OUT:mime.dll
>> /base:0x67700000 /export:luaopen_mime_core mime.o msvcrt.lib lua5.2.lib
>> Microsoft (R) Incremental Linker Version 11.00.50727.1
>> Copyright (C) Microsoft Corporation.  All rights reserved.
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On
>> Behalf Of Luiz Henrique de Figueiredo
>> Sent: Thursday, May 02, 2013 9:58 AM
>> To: Lua mailing list
>> Subject: Re: problem compiling luasocket for lua 5.2 for VS2012
>>
>>> buffer.obj : error LNK2019: unresolved external symbol _lua_tonumberx
>>> referenced in function _buffer_meth_receive
>>
>> This means that you're not linking with Lua 5.2.
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: problem compiling luasocket for lua 5.2 for VS2012

Black, James A.
OK, it compiled.

I was missing a library, Ws2_32.lib
link /DLL /OUT:socket.dll /base:0x67800000 /export:luaopen_socket_core mime.o *.obj msvcrt.lib lua5.2.lib Ws2_32.lib wsock32.lib

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of joao lobato
Sent: Thursday, May 02, 2013 12:31 PM
To: Lua mailing list
Subject: Re: problem compiling luasocket for lua 5.2 for VS2012

Boy, the luasocket bazaar is a bit hectic.

On 02/05/2013, Paul K <[hidden email]> wrote:

> Hi James,
>
> inet_ntop and inet_pton appear to be missing on Windows. I patched
> luasocket for mingw, but it seems like they are not present for VS as
> well. You can find the commit that adds this functionality to
> luasocket here:
> https://github.com/pkulchenko/luasocket/commit/5a58786a39bbef7ed480582
> 1cc921f1d40f12068
>
> For the getaddrinfo you may need to link against ws2_32.
>
> You may want to check build-mingw.sh script I have in this branch
> (https://github.com/pkulchenko/luasocket/commits/lua52-mingw), which
> works for me on Windows.
>
> Paul.
>
> On Thu, May 2, 2013 at 7:50 AM, Black, James A. <[hidden email]> wrote:
>> I closed my console window and reopened it, and now I have this, in
>> part due to I may have been including lua5.1 and 5.2, through
>> different attempts, so I changed my build.bat to this, so I set the
>> environment variable differently:
>> set INCLUDE=C:\Users\jb9\Downloads\lua-5.2.2\src;%INCLUDE%
>> set C:\Users\jb9\Downloads\lua-5.2.2\src;LIB=%LIB%
>>
>>    Creating library socket.lib and object socket.exp inet.obj : error
>> LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced
>> in function _inet_global_getaddrinfo tcp.obj : error LNK2001:
>> unresolved external symbol __imp__getaddrinfo@16 inet.obj : error
>> LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced
>> in function _inet_global_getaddrinfo tcp.obj : error LNK2001:
>> unresolved external symbol __imp__freeaddrinfo@4 inet.obj : error
>> LNK2019: unresolved external symbol __imp__getnameinfo@28 referenced
>> in function _inet_global_getaddrinfo inet.obj : error LNK2019:
>> unresolved external symbol _inet_ntop@16 referenced in function
>> _inet_meth_getpeername udp.obj : error LNK2001: unresolved external
>> symbol _inet_ntop@16 udp.obj : error LNK2019: unresolved external
>> symbol __imp__inet_pton@12 referenced in function _meth_sendto
>> socket.dll : fatal error LNK1120: 5 unresolved externals
>>
>> C:\Users\jb9\Downloads\luasocket\src>link /DLL /OUT:mime.dll
>> /base:0x67700000 /export:luaopen_mime_core mime.o msvcrt.lib
>> lua5.2.lib Microsoft (R) Incremental Linker Version 11.00.50727.1
>> Copyright (C) Microsoft Corporation.  All rights reserved.
>>
>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of Luiz Henrique de
>> Figueiredo
>> Sent: Thursday, May 02, 2013 9:58 AM
>> To: Lua mailing list
>> Subject: Re: problem compiling luasocket for lua 5.2 for VS2012
>>
>>> buffer.obj : error LNK2019: unresolved external symbol
>>> _lua_tonumberx referenced in function _buffer_meth_receive
>>
>> This means that you're not linking with Lua 5.2.
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

Hisham
In reply to this post by joao lobato
On 2 May 2013 13:31, joao lobato <[hidden email]> wrote:
> Boy, the luasocket bazaar is a bit hectic.

The LuaSocket bazaar for Lua 5.2, specifically. We're all waiting for
a release of a version of LuaSocket compatible with Lua 5.2...
LuaSocket is fragmenting fast. :-\

-- Hisham
http://hisham.hm/

Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

Matthew Wild
On 2 May 2013 19:23, Hisham <[hidden email]> wrote:
> On 2 May 2013 13:31, joao lobato <[hidden email]> wrote:
>> Boy, the luasocket bazaar is a bit hectic.
>
> The LuaSocket bazaar for Lua 5.2, specifically. We're all waiting for
> a release of a version of LuaSocket compatible with Lua 5.2...
> LuaSocket is fragmenting fast. :-\

I don't think so. In the months since it has been on github, two forks
have been merged together and upstream, as well as various patches
from community members. I think all that is remaining now is a release
(in any form).

Regards,
Matthew

Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

Jay Carlson
On May 2, 2013, at 3:13 PM, Matthew Wild wrote:

> On 2 May 2013 19:23, Hisham <[hidden email]> wrote:
>> On 2 May 2013 13:31, joao lobato <[hidden email]> wrote:
>>> Boy, the luasocket bazaar is a bit hectic.
>>
>> The LuaSocket bazaar for Lua 5.2, specifically. We're all waiting for
>> a release of a version of LuaSocket compatible with Lua 5.2...
>> LuaSocket is fragmenting fast. :-\
>
> I don't think so. In the months since it has been on github, two forks
> have been merged together and upstream, as well as various patches
> from community members. I think all that is remaining now is a release
> (in any form).

If everyone shipping code is in rough agreement, you might as well give it a name. Actually, that's not quite it--you're reducing the number of names, since currently everyone has their own name for their patched version.

How about a clearly self-deprecating name like LuaRoughSocket 5.2.0.x, or LuaSocket crescente5.2[1]  with a banner <h2>this will be stubbed/symlinked/dpkg-replaced out of existence later</h2>?

Jay

[1]: Uh, trying to be clever in naming things in languages I don't know is probably a bad idea.
Reply | Threaded
Open this post in threaded view
|

Re: problem compiling luasocket for lua 5.2 for VS2012

Matthew Wild
On 4 May 2013 04:31, Jay Carlson <[hidden email]> wrote:

> On May 2, 2013, at 3:13 PM, Matthew Wild wrote:
>
>> On 2 May 2013 19:23, Hisham <[hidden email]> wrote:
>>> On 2 May 2013 13:31, joao lobato <[hidden email]> wrote:
>>>> Boy, the luasocket bazaar is a bit hectic.
>>>
>>> The LuaSocket bazaar for Lua 5.2, specifically. We're all waiting for
>>> a release of a version of LuaSocket compatible with Lua 5.2...
>>> LuaSocket is fragmenting fast. :-\
>>
>> I don't think so. In the months since it has been on github, two forks
>> have been merged together and upstream, as well as various patches
>> from community members. I think all that is remaining now is a release
>> (in any form).
>
> If everyone shipping code is in rough agreement, you might as well give it a name. Actually, that's not quite it--you're reducing the number of names, since currently everyone has their own name for their patched version.
>
> How about a clearly self-deprecating name like LuaRoughSocket 5.2.0.x, or LuaSocket crescente5.2[1]  with a banner <h2>this will be stubbed/symlinked/dpkg-replaced out of existence later</h2>?

That is my backup plan, should we be ready to release the next Prosody
version before LuaSocket is released. And that's looking almost
certain right now. Though I have to say I didn't spend half the time
on naming as you already have :)

Regards,
Matthew