[llvm-dev] lli can't find vsprintf

173 views
Skip to first unread message

jmiguel hernandez via llvm-dev

unread,
Feb 25, 2017, 12:02:04 AM2/25/17
to llvm...@lists.llvm.org
Hi
i am wondering if someone could give me some tips on how to debug/solve this problem. I am trying to use LLI on Windows. I build llvm and clang using cmake. 

clang -c hello.c -emit-llvm -o hello.bc
lli hello.bc
D:\llvm\examples\helloworld>lli hello.bc
LLVM ERROR: Program used external function '___stdio_common_vsprintf' which could not be resolved!

But, I can generate the exe though 
llc -filetype=obj hello.bc
link hello.obj -defaultlib:libcmt

maybe i need a
D:\llvm\examples\helloworld>clang --version
clang version 5.0.0 (trunk 296084) (llvm/trunk 296083)
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: D:\llvm\build\Debug\bin

D:\llvm\examples\helloworld>lli --version
  LLVM version 5.0.0svn
  DEBUG build with assertions.
  Default target: i686-pc-windows-msvc
  Host CPU: broadwell


hello.bc
hello.c

don hinton via llvm-dev

unread,
Feb 25, 2017, 12:30:26 PM2/25/17
to jmiguel hernandez, llvm...@lists.llvm.org
I think you need to tell lli which shared libraries to load, via "-load option," in order to find missing symbols -- probably libcmt in this case, since that's what you passed to link in the llc example.

hth...
Don

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

jmiguel hernandez via llvm-dev

unread,
Feb 27, 2017, 3:44:21 PM2/27/17
to don hinton, llvm...@lists.llvm.org
thank you! yes, i guess that is the problem. 
unfortunately libcmt doesn't work. could it have another name for lli? 

The function missing seems to be part of libcmt since i get a similar error on linking if i remove the libcmt


D:\llvm\examples\helloworld>lli -load=libcmt hello.bc
Error opening 'libcmt': libcmt: Can't open: The specified module could not be found.  (0x7E)
  -load request ignored.
LLVM ERROR: Program used external function '___stdio_common_vsprintf' which could not be resolved!


D:\llvm\examples\helloworld>link hello.obj
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

hello.obj : error LNK2019: unresolved external symbol ___acrt_iob_func referenced in function _printf
hello.obj : error LNK2019: unresolved external symbol ___stdio_common_vsprintf referenced in function __vsnprintf_l
hello.obj : error LNK2019: unresolved external symbol ___stdio_common_vfprintf referenced in function __vfprintf_l
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
hello.exe : fatal error LNK1120: 4 unresolved externals

don hinton via llvm-dev

unread,
Feb 27, 2017, 4:18:23 PM2/27/17
to jmiguel hernandez, llvm...@lists.llvm.org
On Linux I don't need to explicitly load the c standard library, but not sure what happens on windows.  However, I think you need to pass the complete name, and perhaps the path.  On windows I think the name is something like libcmt.lib, but have no idea where it lives.

jmiguel hernandez via llvm-dev

unread,
Feb 27, 2017, 6:00:30 PM2/27/17
to don hinton, llvm...@lists.llvm.org
i think Microsoft deprecated the stdio or something like that.
but i don't know how to link it for lli :(
 
D:\llvm\examples\helloworld>lli -load="c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libcmt.lib" hello.bc
Error opening 'c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libcmt.lib': c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libc
mt.lib: Can't open: Unknown error (0xC1)
  -load request ignored.
LLVM ERROR: Program used external function '___stdio_common_vsprintf' which could not be resolved!

0xc1 is
 ERROR_BAD_EXE_FORMAT
193 (0xC1)

%1 is not a valid Win32 application.

​D:\llvm\examples\helloworld>lli -extra-archive="c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libcmt.lib" hello.bc
LLVM ERROR: Program used external function '___stdio_common_vsprintf' which could not be resolved!

​D:\llvm\examples\helloworld>lli -extra-archive="c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_definitions.lib" hello.bc
LLVM ERROR: Program used external function '___stdio_common_vsprintf' which could not be resolved!



don hinton via llvm-dev

unread,
Feb 27, 2017, 6:39:55 PM2/27/17
to jmiguel hernandez, llvm...@lists.llvm.org
If you have windows and MSVC++, fire it up and see what it links to.

Or google for "default c and c++ libraries for windows" which should pop up a page explaining what ms recommends -- you probably want the multi-threaded dll.

Hth...
Don
Reply all
Reply to author
Forward
0 new messages