lua windows 编译 脚本 生成 lib dll pdb
lua windows 编译 脚本 生成 lib dll pdb
悠米海 发表于4年前
lua windows 编译 脚本 生成 lib dll pdb
  • 发表于 4年前
  • 阅读 1592
  • 收藏 2
  • 点赞 1
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

下载Lua代码,解压进入src目录,创建如下build.bat脚本:

@echo off
del *.obj *.lib *.exe *.dll *.o *.pdb *.exp
cl /MD /O2 /W3 /c /DLUA_BUILD_AS_DLL *.c
ren lua.obj lua.o
ren luac.obj luac.o
link /DLL /IMPLIB:lua52.lib /OUT:lua52.dll /DEBUG /PDB:lua52.pdb *.obj
link /OUT:lua.exe lua.o lua52.lib
lib /out:lua52-static.lib *.obj
link /OUT:luac.exe luac.o lua52-static.lib
del *.obj
mkdir ..\..\lua-5.2
del ..\..\lua-5.2/*
copy lua.exe* ..\..\lua-5.2\
copy luac.exe* ..\..\lua-5.2\
copy lua52.* ..\..\lua-5.2\

打开VS控制台窗口,CD到src目录,执行build.bat

@rem Script to build Lua with MSVC.
@echo off

@if not defined INCLUDE goto :FAIL
@setlocal
 
@if "%1"=="clean" goto :CLEAN
 
@set CC=cl
@set LD=link
@set AR=lib
@set RC=rc
@set CP=copy
 
@set DBG_CFLAGS=/nologo /c /Zi /Od /Ob0 /RTC1 /MD
@set CFLAGS=/nologo /c /O2 /W3
@set CFLAGS_MD=/MD
@set CFLAGS_MT=/MT
@set LDFLAGS=
 
@set LUA_CFLAGS=/DNDEBUG /D_WINDOWS /DWIN32 /DWINNT
     
@set LUA_SRC=lapi.c lauxlib.c lbaselib.c lbitlib.c lcode.c lcorolib.c lctype.c ldblib.c ldebug.c^
			 ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c loadlib.c lobject.c^
			 lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c^
			 lutf8lib.c lvm.c lzio.c 

@set DEP_LIB=

cd src
@rem clean
del *.lib *.obj *.manifest *.exp *.dll *.exe

@rem Multithreaded, dynamic link
%CC% %CFLAGS_MD% %CFLAGS% %LUA_CFLAGS% %LUA_SRC%
%AR% /OUT:lua53-md.lib *.obj
%LD% /DLL /OUT:lua53-md.dll *.obj
del *.obj *.manifest
 
@rem Multithreaded, static link
%CC% %CFLAGS_MT% %CFLAGS% %LUA_CFLAGS% %LUA_SRC%
%AR% /OUT:lua53-mt.lib *.obj
%LD% /DLL /OUT:lua53-mt.dll *.obj
del *.obj *.manifest
 
@rem Debug, /MD
%CC% %DBG_CFLAGS% %LUA_CFLAGS% %LUA_SRC%
%AR% /OUT:lua53-dbg.lib *.obj
%LD% /DLL /OUT:lua53-dbg.dll *.obj
del *.obj *.manifest

@rem Multithreaded, dynamic lua.exe
%CC% %CFLAGS_MT% %CFLAGS% %LUA_CFLAGS% lua.c
%LD% /OUT:lua.exe lua.obj lua53-mt.lib %DEP_LIB%
del *.obj *.manifest *.exp

@rem Multithreaded, dynamic luac.exe
%CC% %CFLAGS_MT% %CFLAGS% %LUA_CFLAGS% luac.c
%LD% /OUT:luac.exe luac.obj lua53-mt.lib %DEP_LIB%
del *.obj *.manifest *.exp
 
@goto :COPY

:COPY
xcopy *.exe ..\out\bin\ /s /e /y
xcopy *.lib ..\out\lib\ /s /e /y
xcopy *.dll ..\out\lib\ /s /e /y
md ..\out\include
copy lua.h ..\out\include\ /y
copy lauxlib.h ..\out\include\ /y
copy luaconf.h ..\out\include\ /y
copy lualib.h ..\out\include\ /y
@goto :CLEAN
 
:CLEAN
del *.lib *.obj *.manifest *.exp *.dll *.exe
@goto :END

:FAIL
@echo You must open a "Visual Studio .NET Command Prompt" to run this script
@goto :END

:END
PAUSE




共有 人打赏支持
粉丝 13
博文 91
码字总数 36984
×
悠米海
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: