c - 使用 emscripten 找不到 Windows.h

标签 c windows llvm file-not-found

我正在尝试在 Windows 上使用 Emscripten 转换 javascript 中的 C 库。我使用了教程 here设置 emscripten 和 LLVM/Clang 开始。我用Visual Studio 2010编译了LLVM,clang的版本是:

clang 版本 3.2 (tags/RELEASE_32/final)
目标:i686-pc-win32
线程模型:posix

在命令行上,我写下这行来编译我的文件:

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

这是我得到的输出和最终的错误(以及我寻求帮助的原因......)

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

C 文件不使用任何 MFC,据我了解,3.2 版的 clang 应该能够使用标准的 Windows API。我检查了是否可以找到 Windows.h,它位于 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include

我是否遗漏了什么,例如指定我正在使用 Win32 进行编译的配置或标志?我还注意到在 llvm 存储库中,Windows.h 文件位于 lib/Support/Windows 中,但我不知道它的用途是什么。这看起来像是某种可移植性包装器,可以使用来自不同库的标准 C++。

我不知道从那里去哪里,我们将不胜感激。

最佳答案

Emscripten 没有所需的 Javascript 端口文件,例如 windows.h 或 OSX 的 Cocoa。

唯一的解决方案是将您的代码移植到 SDL,因为 SDL 在 emscripten 及其 header 中可用。

关于c - 使用 emscripten 找不到 Windows.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15773253/

相关文章:

c - 使用 C 中名为 getfullpathname() 的函数解析路径?

c++ - 不同数据类型的sizeof(datatype pointer)/sizeof(data type)取值不同,为什么?

c - 如何在 GCC 中编译 C 程序以在 WinDbg 中启用调试?

c++ - 链接不支持异常处理的代码 (C++/LLVM)

LLVM 获取指令的操作数和左值名称

使用 CMake 正确设置链接器标志

c++ - C++ 中的复杂矩阵指数

c# - 捕获 ASP.NET C# 中的所有异常,而不是捕获 `try{} catch{}` block 中的每个方法

windows - KOHA ILS(集成图书馆系统)在 Windows 7 64 位中的安装

c++ - 我想根据前一条指令的结果更改 GEP 的索引