jmckaskill / luaffi

Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.
469 stars 84 forks source link

Windows build failure (VS2010) #3

Closed daurnimator closed 12 years ago

daurnimator commented 12 years ago

U:\Programming\luaffi>msvcbuild.bat

U:\Programming\luaffi>"C:\Program Files (x86)\Lua\5.1\lua.exe" dynasm\dynasm.lua -LNE -D X32WIN -o call_x86.h call_x86.dasc

U:\Programming\luaffi>"C:\Program Files (x86)\Lua\5.1\lua.exe" dynasm\dynasm.lua -LNE -D X64 -o call_x64.h call_x86.dasc

U:\Programming\luaffi>"C:\Program Files (x86)\Lua\5.1\lua.exe" dynasm\dynasm.lua -LNE -D X64 -D X64WIN -o call_x64win.h call_x86.dasc

U:\Programming\luaffi>"C:\Program Files (x86)\Lua\5.1\lua.exe" dynasm\dynasm.lua -LNE -o call_arm.h call_arm.dasc

U:\Programming\luaffi>cl.exe /nologo /c /MD /Ox /W3 /Zi /WX /D_CRT_SECURE_NO_DEP RECATE /DLUA_FFI_BUILD_AS_DLL /I"msvc" /I"." /I"C:\Program Files (x86)\Lua\5.1\i nclude" /DLUA_DLL_NAME="C:\Program Files (x86)\Lua\5.1\lua5.1.dll" call.c ctype. c ffi.c parser.c call.c ctype.c ffi.c ffi.c(1882) : error C2220: warning treated as error - no 'object' file generated

ffi.c(1882) : warning C4129: 'P' : unrecognized character escape sequence ffi.c(1882) : warning C4129: 'L' : unrecognized character escape sequence ffi.c(1882) : warning C4129: 'l' : unrecognized character escape sequence parser.c Generating Code...

U:\Programming\luaffi>link.exe /nologo /debug /DLL /OUT:ffi.dll "C:\Program File s (x86)\Lua\5.1\lib\lua5.1.lib" *.obj call.obj : error LNK2019: unresolved external symbol _unpack_varargs_int referen ced in function _reserve_code call.obj : error LNK2019: unresolved external symbol _unpack_varargs_float refer enced in function _reserve_code call.obj : error LNK2019: unresolved external symbol _unpack_varargs_reg referen ced in function _reserve_code call.obj : error LNK2019: unresolved external symbol _unpack_varargs_stack_skip referenced in function _reserve_code call.obj : error LNK2019: unresolved external symbol _unpack_varargs_stack refer enced in function _reserve_code call.obj : error LNK2019: unresolved external symbol _to_typed_function referenc ed in function _reserve_code call.obj : error LNK2019: unresolved external symbol _to_typed_pointer reference d in function _reserve_code call.obj : error LNK2019: unresolved external symbol _to_enum referenced in func tion _reserve_code call.obj : error LNK2019: unresolved external symbol _to_uintptr referenced in f unction _reserve_code call.obj : error LNK2019: unresolved external symbol _to_uint32 referenced in fu nction _reserve_code call.obj : error LNK2019: unresolved external symbol _to_int32 referenced in fun ction _reserve_code call.obj : error LNK2019: unresolved external symbol _to_int64 referenced in fun ction _reserve_code call.obj : error LNK2019: unresolved external symbol _to_uint64 referenced in fu nction _reserve_code call.obj : error LNK2019: unresolved external symbol _to_float referenced in fun ction _reserve_code call.obj : error LNK2019: unresolved external symbol _to_double referenced in fu nction _reserve_code ffi.dll : fatal error LNK1120: 15 unresolved externals

U:\Programming\luaffi>if exist ffi.dll.manifest mt.exe /nologo -manifest ffi.dll .manifest -outputresource:"ffi.dll;2"

U:\Programming\luaffi>cl.exe /nologo /c /MD /Ox /W3 /Zi /WX /D_CRT_SECURE_NO_DEP RECATE /DLUA_FFI_BUILD_AS_DLL /I"msvc" /Gd test.c /Fo"test_cdecl.obj" test.c

U:\Programming\luaffi>cl.exe /nologo /c /MD /Ox /W3 /Zi /WX /D_CRT_SECURE_NO_DEP RECATE /DLUA_FFI_BUILD_AS_DLL /I"msvc" /Gz test.c /Fo"test_stdcall.obj" test.c

U:\Programming\luaffi>cl.exe /nologo /c /MD /Ox /W3 /Zi /WX /D_CRT_SECURE_NO_DEP RECATE /DLUA_FFI_BUILD_AS_DLL /I"msvc" /Gr test.c /Fo"test_fastcall.obj" test.c

U:\Programming\luaffi>link.exe /nologo /debug /DLL /OUT:test_cdecl.dll test_cdec l.obj LINK : test_cdecl.dll not found or not built by the last incremental link; perfo rming full link Creating library test_cdecl.lib and object test_cdecl.exp

U:\Programming\luaffi>link.exe /nologo /debug /DLL /OUT:test_stdcall.dll test_st dcall.obj LINK : test_stdcall.dll not found or not built by the last incremental link; per forming full link Creating library test_stdcall.lib and object test_stdcall.exp

U:\Programming\luaffi>link.exe /nologo /debug /DLL /OUT:test_fastcall.dll test_f astcall.obj LINK : test_fastcall.dll not found or not built by the last incremental link; pe rforming full link Creating library test_fastcall.lib and object test_fastcall.exp

U:\Programming\luaffi>if exist test_cdecl.dll.manifest mt.exe /nologo -manifest test_cdecl.dll.manifest -outputresource:"test_cdecl.dll;2"

U:\Programming\luaffi>if exist test_stdcall.dll.manifest mt.exe /nologo -manifes t test_stdcall.dll.manifest -outputresource:"test_stdcall.dll;2"

U:\Programming\luaffi>if exist test_fastcall.dll.manifest mt.exe /nologo -manife st test_fastcall.dll.manifest -outputresource:"test_fastcall.dll;2"

U:\Programming\luaffi>del .obj .manifest

jmckaskill commented 12 years ago

Thanks, your issue is that LUA_DLL is used as a c string so any backslashes need to be escaped. E.G. change it to @set LUA_DLL=C:\Program Files (x86)\Lua\5.1\lua5.1.dll

daurnimator commented 12 years ago

Thanks; anything you can do to avoid that?

Otherwise, I just noticed your "RELEASE" build does a debug link anyway

jmckaskill commented 12 years ago

Actually thinking about this a bit further, you shouldn't have to use the path at all. The LUA_DLL variable only needs to contain the lua dll name not the full path as the dll has to be on the PATH anyways. I'll check in a commit that further clarifies this.

As for release building debug, thats actually on purpose. The cl command line builds optimized code (/MD and /Ox) with debug info (/Zi). The link then has the /debug arg so that the pdb is generated to be able to debug the release exe. Note that as the debug info is in a separate file, this does not increase the size of the exe, but comes in very handy if you need to debug it.