help please? lauc.exe link errors, 5.1 source/win32?

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

help please? lauc.exe link errors, 5.1 source/win32?

Thomas Blom
Hello all,

I'm just getting started with Lua.  I want to use it to execute scripts  
 from my C++ apps.

I downloaded (the official, I presume) 5.1 source from the link at  
lua.org.  I'm able to compile all the .c files to a dll/lib, and can  
compile lua.c and link it with the lib to create a working lua.exe  
interpreter.

However, my attempts to build the compiler (luac.exe) by compiling  
luac.c/print.c and linking to the lib produce these link errors:

C:\lang\lua-5.1\src>link /out:luac.exe luac.obj print.obj lua51.lib
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation.  All rights reserved.

luac.obj : error LNK2019: unresolved external symbol _luaM_toobig  
referenced in function _combine
luac.obj : error LNK2019: unresolved external symbol _luaM_realloc_  
referenced in function _combine
luac.obj : error LNK2019: unresolved external symbol _luaS_newlstr  
referenced in function _combine
luac.obj : error LNK2019: unresolved external symbol _luaD_growstack  
referenced in function _combine
luac.obj : error LNK2019: unresolved external symbol _luaF_newproto  
referenced in function _combine
luac.obj : error LNK2019: unresolved external symbol _luaU_dump referenced  
in function _pmain
print.obj : error LNK2019: unresolved external symbol _luaP_opmodes  
referenced in function _PrintCode
print.obj : error LNK2019: unresolved external symbol _luaP_opnames  
referenced in function _PrintCode
luac.exe : fatal error LNK1120: 8 unresolved externals

All .c files were compiled with the same (minimal) options, as given in  
the luavs.bat example that is part of the source distribution:

cl /O2 /W3 /c /DLUA_BUILD_AS_DLL luac.c print.c

I've tried omitting the ...DLL switch here, which toggles  
declspec(import/export) but errors are the same regardless.

I'm building with the .net 2003 version of the ms tools.

Anyone already done this/fixed this?

thanks -thomas

Reply | Threaded
Open this post in threaded view
|

Re: help please? lauc.exe link errors, 5.1 source/win32?

D Burgess-4
> I'm building with the .net 2003 version of the ms tools.

1.  you need print.obj and lopcodes.obj
2.  you need to either link luac statically or export the missing
entry points (from the DLL).
I would suggest a static link.

DB
Reply | Threaded
Open this post in threaded view
|

Re: help please? lauc.exe link errors, 5.1 source/win32?

Thomas Blom
>> I'm building with the .net 2003 version of the ms tools.
>
> 1.  you need print.obj and lopcodes.obj
> 2.  you need to either link luac statically or export the missing
> entry points (from the DLL).
> I would suggest a static link.

Thanks!  A modifed luavs.bat run from outside the src directory for users  
of .net 2003 (win32):

-------
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
link /DLL /out:lua51.dll l*.obj
lib /out:lua51static.lib l*.obj

cl /O2 /W3 /c /DLUA_BUILD_AS_DLL lua.c
link /out:lua.exe lua.obj lua51.lib

cl /O2 /W3 /c luac.c print.c
link /out:luac.exe luac.obj print.obj lua51static.lib
-------

(run the vsvars32.bat to setup cmdline paths etc if necessary)

Running lua.exe causes lua51.dll to load.  luac.exe instead is statically  
linked.  Note the last link command causes a luac.lib to get produced  
also, which is 23k compared to the lua51static.lib of almost 500k. The  
resultant luac.exe is only 155k, so I assume luac.lib is the functionality  
actually required by luac.exe, and is what gets actually included, though  
I'm not completely clear about this (sorry, long since brainwashed by  
IDEs).

-thomas