4

I'm trying to convert a C library in javascript using Emscripten on Windows. I used the tutorial here to setup emscripten and LLVM/Clang to get started. I compiled LLVM with Visual Studio 2010. The version of clang is:

clang version 3.2 (tags/RELEASE_32/final)
Target: i686-pc-win32
Thread model: posix

On the command line, I write this line to compile my file:

C:\emscripten>python emcc -v \mypath\myfile.c

and this is the output and ultimately the error I get (and the reason why I'm asking help...)

emcc: compiling to bitcode
emcc: compiling source file:  \mypath\myfile.c
emcc running: C:\llvm\build\bin\release\clang -m32 -U__i386__ -U__x86_64__ -U__i
386 -U__x86_64 -Ui386 -Ux86_64 -U__SSE__ -U__SSE2__ -U__MMX__ -UX87_DOUBLE_ROUND
ING -UHAVE_GCC_ASM_FOR_X87 -DEMSCRIPTEN -U__STRICT_ANSI__ -U__CYGWIN__ -D__STDC_
_ -Xclang -triple=i386-pc-linux-gnu -D__IEEE_LITTLE_ENDIAN -fno-math-errno -fno-
ms-compatibility -nostdinc -Xclang -nobuiltininc -Xclang -nostdsysteminc -Xclang
 -isystemC:\emscripten\system\local\include -Xclang -isystemC:\emscripten\system
\include\libcxx -Xclang -isystemC:\emscripten\system\include -Xclang -isystemC:\
emscripten\system\include\emscripten -Xclang -isystemC:\emscripten\system\includ
e\bsd -Xclang -isystemC:\emscripten\system\include\libc -Xclang -isystemC:\emscr
ipten\system\lib\libcxxabi\include -Xclang -isystemC:\emscripten\system\include\
gfx -Xclang -isystemC:\emscripten\system\include\net -Xclang -isystemC:\emscript
en\system\include\SDL -U__APPLE__ -U__linux__ -D_LIBCPP_HAS_NO_DELETED_FUNCTIONS
 -v -emit-llvm -c \mypath\myfile.c -o C:\tempo\tmpn8yiq5\myfile_0.o
clang version 3.2 (tags/RELEASE_32/final)
Target: i686-pc-win32
Thread model: posix
 "C:/llvm/build/bin/release/clang.exe" -cc1 -triple i686-pc-win32 -emit-llvm-bc
-disable-free -disable-llvm-verifier -main-file-name myfile.c -mrelocation-mod
el static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu pent
ium4 -momit-leaf-frame-pointer -v -coverage-file "C:\\tempo\\tmpn8yiq5\\myfile_0
.o" -nostdsysteminc -nobuiltininc -resource-dir "C:/llvm/build/bin/release\\..
\\lib\\clang\\3.2" -U __i386__ -U __x86_64__ -U __i386 -U __x86_64 -U i386 -U x8
6_64 -U __SSE__ -U __SSE2__ -U __MMX__ -U X87_DOUBLE_ROUNDING -U HAVE_GCC_ASM_FO
R_X87 -D EMSCRIPTEN -U __STRICT_ANSI__ -U __CYGWIN__ -D __STDC__ -D __IEEE_LITTL
E_ENDIAN -U __APPLE__ -U __linux__ -D _LIBCPP_HAS_NO_DELETED_FUNCTIONS -fmodule-
cache-path "C:\\Users\\SS\\AppData\\Local\\Temp\\clang-module-cache" -ferror-lim
it 19 -fmessage-length 80 -mstackrealign -fms-extensions -fmsc-version=1300 -fde
layed-template-parsing -fobjc-runtime=gcc -fobjc-default-synthesize-properties -
fdiagnostics-show-option -fcolor-diagnostics -triple=i386-pc-linux-gnu -nobuilti
ninc -nostdsysteminc "-isystemC:\\emscripten\\system\\local\\include" "-isystemC
:\\emscripten\\system\\include\\libcxx" "-isystemC:\\emscripten\\system\\include
" "-isystemC:\\emscripten\\system\\include\\emscripten" "-isystemC:\\emscripten\
\system\\include\\bsd" "-isystemC:\\emscripten\\system\\include\\libc" "-isystem
C:\\emscripten\\system\\lib\\libcxxabi\\include" "-isystemC:\\emscripten\\system
\\include\\gfx" "-isystemC:\\emscripten\\system\\include\\net" "-isystemC:\\emsc
ripten\\system\\include\\SDL" -o "C:\\tempo\\tmpn8yiq5\\myfile_0.o" -x c "\\mypa
th\\myfile.c"
clang -cc1 version 3.2 based upon LLVM 3.2svn default target i686-pc-win32
ignoring nonexistent directory "C:\emscripten\system\local\include"
#include "..." search starts here:
#include <...> search starts here:
 C:\emscripten\system\include\libcxx
 C:\emscripten\system\include
 C:\emscripten\system\include\emscripten
 C:\emscripten\system\include\bsd
 C:\emscripten\system\include\libc
 C:\emscripten\system\lib\libcxxabi\include
 C:\emscripten\system\include\gfx
 C:\emscripten\system\include\net
 C:\emscripten\system\include\SDL
End of search list.
\mypath\myfile.c:4:10: fatal error: 'windows.h'
      file not found
#include <windows.h>
         ^
1 error generated.
emcc: compiler frontend failed to generate LLVM bitcode, halting

The C file does not use any MFC and as I understand it, version 3.2 of clang should be able to use the standard windows API. I checked if Windows.h is somewhere to be found and it is located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include

Did I miss something, like a configuration or flag that specifies that I'm compiling with Win32? I also noticed that in the llvm repository, there is the Windows.h file located in lib/Support/Windows but I don't know what is its purpose. This looks like some sort of portability wrapper to use the standard C++ from different libraries.

I don't know where to go from there and any help would be appreciated.

Simon Senécal
  • 111
  • 2
  • 6
  • 1
    Shouldn't you have "-I C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Include" on your compile line? – Jay Apr 02 '13 at 20:07
  • That's what I thought at first but since emcc is used to cross-compile, it uses the system headers bundled with Emscripten. In the Emscripten tutorial, it is specified that: "One thing to be aware of is if you build a project that has hardcoded includes, for example -I/usr/include/something: Using system headers that way is dangerous when you are cross-compiling, since the headers are meant for your local system, not for the platform you are actually building for." – Simon Senécal Apr 02 '13 at 20:31
  • 1
    I don't think emscripten comes with WinAPI implementation - it's not part of the [default distribution](https://github.com/kripken/emscripten/tree/master/system/include) and I'm not sure it'll happen any time soon: basically, you'd need to port WINE... – Christoph Apr 02 '13 at 20:44
  • @SimonSenécal Any update on this? – Tarun Gehlaut Apr 09 '16 at 18:09

1 Answers1

-1

Emscripten does not have the required Javascript port of files such as windows.h or OSX's Cocoa.

The only solution is to port your code to SDL, as SDL is available in emscripten and hence its headers.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
Tarun Gehlaut
  • 1,292
  • 10
  • 16