lua-users home
lua-l archive

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

Hi group,

So I wanted to move my project to use MSVCRT.DLL for LuaJIT (but the it's also related to lua, and Windows in general).

With VS2008, VS2010 that is no longer possible, but after some googling I found this wonderful page:

The solution is to use WDK and link to msvcrt_2000.obj (32-bit only).

More clues on google:

Whether it's safe or not, I can't tell. But it works for on my laptop with Windows XP (actually bootcamped MacBook), and at work Vista 64 Business and Windows 7.

Here is the file that I'm compiling luajit with (it could work for other things too).


rem This is
rem   E:\p\ufo\build\Windows\luajit-wdk.cmd
rem Assuming LuaJit (2.00+) is here:
rem   E:\p\luajit
rem and that these folders exists
rem   E:\p\ufo\bin\Windows\x86
rem   E:\p\ufo\bin\Windows\x64
rem also assumes that the Windows DDK is located here
rem   (change it, or provided as second parameter):
rem   e:\apps\wdk
rem and that lua is installed and on the PATH (I've used cygwin one)
rem if not - just remove the line where I'm deleteing buildvm-*.h files
rem First parameter to the batch file is 32 or 64

@echo off

set _UFODIR=%~dp0..\..
set _LUAJITDIR=%_UFODIR%\..\luajit\src
set _ARCH=%1
set _WDK=%2

if "%_ARCH%"==""   set _ARCH=32
if "%_WDK%"==""    set _WDK=e:\apps\wdk
if "%_ARCH%"=="32" set _TARGET=i386
if "%_ARCH%"=="32" set _LUA_ARCH=x86
if "%_ARCH%"=="64" set _TARGET=amd64
if "%_ARCH%"=="64" set _LUA_ARCH=x64
if "%_TARGET%"=="" (
    echo You should specify 32 or 64 as first argument
    goto :EOF

if "%_TARGET%"=="amd64" set _CROSS_TARGET=x32-64

call %_WDK%\bin\setenv.bat %_WDK% fre %_CROSS_TARGET% win7 no_oacr

set LIB=%BASEDIR%\lib\crt\%_TARGET%;%BASEDIR%\lib\win7\%_TARGET%;%LIB%

pushd %_LUAJITDIR%
del *.obj buildvm_*.h 1>nul 2>nul
del link.cmd cl.cmd 1>nul 2>nul
echo cl.exe /D_MSC_VER=1399 %%* > cl.cmd
if "%_TARGET%"=="i386" echo link.exe %_WDK%\lib\win7\%_TARGET%\msvcrt_win2000.obj %%* > link.cmd
call msvcbuild amalg
del link.cmd cl.cmd 1>nul 2>nul
git log -1 >> lua51.dll
git log -1 >> luajit.exe
call :install lua51.dll  %_UFODIR%\bin\Windows\%_LUA_ARCH%
call :install luajit.exe %_UFODIR%\bin\Windows\%_LUA_ARCH%
goto :EOF

echo install: [move /y %*]
move /y %*
goto :EOF


Also this ugly diff (on my side). Unfortunately if batch file is to be called it has to be.... ahem "call"-ed (my cl.bat that later calls cl.exe is such)


E:\p\luajit\src>git diff msvcbuild.bat
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index c7e5df6..b718a8a 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -14,8 +14,8 @@
 @if not defined INCLUDE goto :FAIL

-@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
-@set LJLINK=link /nologo
+@set LJCOMPILE=call cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
+@set LJLINK=call link /nologo
 @set LJMT=mt /nologo
 @set LJLIB=lib /nologo
 @set DASMDIR=..\dynasm

Dimiter "malkia" Stanev.