Re: cannot resolve symbol 'printf' with ffi (msvc 14.0)

  • From: Peter Cawley <corsix@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 16 Apr 2017 11:41:59 +0100

I'd be tempted to explore something like the following, which'll
instantiate all of the stdio inline functions as exported function
symbols from the LuaJIT DLL:

diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index 5648a89..71bde75 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -14,7 +14,7 @@
 @if not defined INCLUDE goto :FAIL

 @setlocal
-@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
+@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
/D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
 @set LJLINK=link /nologo
 @set LJMT=mt /nologo
 @set LJLIB=lib /nologo /nodefaultlib

On Sun, Apr 16, 2017 at 10:30 AM, Thomas Jammet <jammetthomas@xxxxxxxxx> wrote:

Ok thank you, this is a bad news.
Do you know if there is a way to link luajit with
legacy_stdio_definitions.lib?

Regards

--

Thomas JAMMET
Freelancer - MonaServer.ovh
14 Place Maschat - 19000 Tulle (France)
Tel : +336 23 46 39 80
http://fr.linkedin.com/pub/thomas-jammet/5a/411/60b/

2017-04-15 23:51 GMT+02:00 Peter Cawley <corsix@xxxxxxxxxx>:

(Binaries received, though it also looks like I can also reproduce
with my local MSVC 2015)

I wasn't previously aware of it, but it looks like printf et. al.
don't exist as functions in Microsoft's CRT since MSVC2015 (see

https://msdn.microsoft.com/en-us/library/bb531344.aspx#stdio-h-and-conio-h).
As they don't exist as functions in the CRT (or kernel32 or user32 or
gdi32), it is no surprise that ffi.C can't find them. Looking through
the CRT headers, it looks like you don't reach an actual "real"
function until __stdio_common_vfprintf.

On Sat, Apr 15, 2017 at 7:06 PM, Peter Cawley <corsix@xxxxxxxxxx> wrote:
I can't reproduce this problem with your latest published binaries
(from
http://sourceforge.net/projects/monaserver/files/MonaServer_1.2_Win32.zip/download)
- could you share the (presumably Debug build) binaries which you're
using? (I'm not sure whether the list will like executable
attachments; feel free to send to me privately if necessary)

On Sat, Apr 15, 2017 at 6:33 PM, Thomas Jammet <jammetthomas@xxxxxxxxx>
wrote:
No sorry, it gives the same result. Not event with "printf_s".

--

Thomas JAMMET
Freelancer - MonaServer.ovh
14 Place Maschat - 19000 Tulle (France)
Tel : +336 23 46 39 80
http://fr.linkedin.com/pub/thomas-jammet/5a/411/60b/

2017-04-15 19:27 GMT+02:00 Ryan Gonzalez <rymg19@xxxxxxxxx>:

Does it work if you try using _printf instead?

--
Ryan (ライアン)
Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone
else
http://refi64.com/

On Apr 15 2017, at 11:37 am, Thomas Jammet <jammetthomas@xxxxxxxxx>
wrote:

I am trying to run the basic example from FFI :

local ffi = require("ffi")
ffi.cdef[[
int printf(const char *fmt, ...);
]]
ffi.C.printf("Hello %s!", "world")

And here is the result :

cannot resolve symbol 'printf': The specified procedure could not be
found.

stack traceback:
        [C]: in function '__index'

...rkspace\MonaServer\MonaServer\Debug\www\testffi\main.lua:5: in
main chunk
        [C]: at 0x00281dc0

I don't know what I am missing but functions from stdio seems not
available.
I have compiled luajit with Visual Studio Express 2015 (v.
14.0.25420.01
Update 3). I have tried with last commit
(247b3624ffa7f01ee39fb62d4c1b0d1de0f5ef9b) and with releases 2.0.4,
2.0.1,
2.0.0 but it is always giving the same result. Any idea?

In addition I haven't built luajit with any parameters, just
"msvcbuild.bat" from VS2015 command prompt.

Thank you





Other related posts: