[cfe-dev] LLVM/Clang Windows XP 32bit - MessageBox

Peter Hanzel hanzelpeter at gmail.com
Fri Dec 9 04:04:28 PST 2011


Hello.

Adding this:

#define WINVER 0x0500
#define _WIN32_WINNT 0x0500

before include of <windows.h> helped.

Thanks a lot.

P.S. I attached disassembled main.o, becuase I don't know if the generated stuff is needed in that bc file.
  ----- Original Message ----- 
  From: Ruben Van Boxem 
  To: Peter Hanzel 
  Cc: cfe-dev at cs.uiuc.edu 
  Sent: Friday, December 09, 2011 12:14 PM
  Subject: Re: [cfe-dev] LLVM/Clang Windows XP 32bit - MessageBox


  Op 9 dec. 2011 11:48 schreef "Peter Hanzel" <hanzelpeter at gmail.com> het volgende:
  >
  > Hello.
  >
  > I have downloaded CLANG 3.0 and successfuly build on Windows XP.
  > Now I tried to compile this simple MessageBox Win32 Api program:
  >
  > #include <windows.h>
  >
  > int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  > MessageBox(NULL, "hello msgbox world\n", "Title", MB_OK);
  > return 0;
  > }
  >
  > I did it this way:
  >
  > clang -c -emit-llvm main.c
  > llc -filetype obj main.o -o test.obj
  > link test.obj user32.lib msvcrt.lib
  >
  > But when I run test.exe I get : The procedure entry point InterlockedCompareExchange64 could not be located in dynamic link library KERNEL32.dll.
  >
  > So I dissassembled main.o and there is usage of: (attached to mail)
  >
  > declare dllimport x86_stdcallcc i64 @InterlockedCompareExchange64(i64*, i64, i64)
  >
  > But I think this is valid only for 64bit or Vista and more.
  > So I deleted whole stuff which is not needed to compile it.
  > Then with:
  >
  > llvm-dis main.o
  > edit main.o.ll --remove 64bit stuff
  > llvm-as main.o.ll -o main.o
  > llc -filetype obj main.o -o test.obj
  > link test.obj user32.lib msvcrt.lib
  >
  > And I got valid test.exe application, which also works.
  >
  > So my question is: Is this Adding of unwanted stuff correct or is it some kind of bug?

  Did you define the winver macro correctly? Does the problem still occur then?

  Ruben
  >
  > Peter.
  >
  >
  > _______________________________________________
  > cfe-dev mailing list
  > cfe-dev at cs.uiuc.edu
  > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
  >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111209/e02e4429/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.o.ll
Type: application/octet-stream
Size: 16156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111209/e02e4429/attachment.obj>


More information about the cfe-dev mailing list