emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.86k stars 3.32k forks source link

emcmake with Visual Studio generator doesn't work as expected #14688

Open Nir-Az opened 3 years ago

Nir-Az commented 3 years ago

Hi,

I tried for 2 days to configure and compile my project to Wasm using Emcmake.

Can it be that emcmake does not support Visual Studio generator?

No matter what I try it keeps compiling with CL.exe instead of emcc/em++.

I didn't find a disclaimer on VS generator on the docs.

What am I missing?

Thanks

sbc100 commented 3 years ago

I think the VS generator for cmake is simply not compatible with custom or cross compilers like emscripten. If this isn't mentioned in the docs then perhaps it should be.

sbc100 commented 3 years ago

Have you been able to use any other cross compilers with the VS generator?

Nir-Az commented 3 years ago

@sbc100 thanks for the reply,

emcc is the only once I tried. I tried setting MinGW as the generator but than I get errors about including windows header files. Any idea why?

sbc100 commented 3 years ago

MinGW makefile generator should work fine.

Can you share the full command lines you used as well as the full output.

BTW I recommend the Ninja generator since its fully cross platfrom and has several important benefits over normal Makefiles (its parallel by default, and its always displays the full failing command when something goes wrong).

Nir-Az commented 3 years ago

Thanks for the reply,

The command is : emcmake cmake .. "MinGW Makefiles" cmake --build . --config Release -- -m

I cannot run it currently but the the output was from one of the files: fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory The project builds with Visual Studio. Can it be that I cannot use windows headers with a project compiled with emcc?

Thanks

sbc100 commented 3 years ago

If you are seeing fatal error C1083: then you are still suing MSVC and not emcc to compile.

Can you try removing the entire tree and re-running emcmake? Also, you can add --verbose to the emcmake to generate a Makefile that actually shows the commands its running to it more clear what is going on.

sbc100 commented 3 years ago

sys/time.h should work fine with emscripten, its a standard header.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.