Emscripten + Mingw : The C compiler is not able to compile a simple test program.
已回答
Hello everyone!
I am trying to run a small program using emscripten (c++ to wasm).
The error I get:
-- The C compiler identification is Clang 12.0.0
-- The CXX compiler identification is Clang 12.0.0
-- Check for working C compiler: C:/cpp/emsdk/upstream/emscripten/emcc.bat
-- Check for working C compiler: C:/cpp/emsdk/upstream/emscripten/emcc.bat - broken
CMake Error at C:/Program Files/JetBrains/CLion 2020.3/bin/cmake/win/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/cpp/emsdk/upstream/emscripten/emcc.bat"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/cpp/wasmd/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/cpp/mingw/mingw64/bin/mingw32-make.exe cmTC_dff77/fast && C:/cpp/mingw/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_dff77.dir\build.make CMakeFiles/cmTC_dff77.dir/build
mingw32-make.exe[1]: Entering directory 'C:/cpp/wasmd/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_dff77.dir/testCCompiler.c.obj
C:\cpp\emsdk\upstream\emscripten\emcc.bat -o CMakeFiles\cmTC_dff77.dir\testCCompiler.c.obj -c C:\cpp\wasmd\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c
Linking C executable cmTC_dff77.exe
"C:\Program Files\JetBrains\CLion 2020.3\bin\cmake\win\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_dff77.dir\link.txt --verbose=1
"C:\Program Files\JetBrains\CLion 2020.3\bin\cmake\win\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_dff77.dir/objects.a
C:\cpp\mingw\mingw64\bin\ar.exe cr CMakeFiles\cmTC_dff77.dir/objects.a @CMakeFiles\cmTC_dff77.dir\objects1.rsp
C:\cpp\emsdk\upstream\emscripten\emcc.bat -Wl,--whole-archive CMakeFiles\cmTC_dff77.dir/objects.a -Wl,--no-whole-archive -o cmTC_dff77.exe -Wl,--out-implib,libcmTC_dff77.dll.a -Wl,--major-image-version,0,--minor-image-version,0
emcc: warning: CMakeFiles\cmTC_dff77.dir/objects.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
emcc: warning: CMakeFiles\cmTC_dff77.dir/objects.a: adding index [-Wemcc]
wasm-ld: error: unknown argument: --out-implib
wasm-ld: error: unknown argument: --major-image-version
wasm-ld: error: unknown argument: --minor-image-version
wasm-ld: error: cannot open libcmTC_dff77.dll.a: no such file or directory
wasm-ld: error: cannot open 0: no such file or directory
wasm-ld: error: cannot open 0: no such file or directory
emcc: error: 'C:/cpp/emsdk/upstream/bin\wasm-ld.exe -o cmTC_dff77.wasm --whole-archive CMakeFiles\cmTC_dff77.dir/objects.a --no-whole-archive -LC:\cpp\emsdk\upstream\emscripten\system\local\lib -LC:\cpp\emsdk\upstream\emscripten\system\lib --out-implib -LC:\cpp\emsdk\upstream\emscripten\cache\wasm libcmTC_dff77.dll.a --major-image-version 0 --minor-image-version 0 C:\cpp\emsdk\upstream\emscripten\cache\wasm\libc.a C:\cpp\emsdk\upstream\emscripten\cache\wasm\libcompiler_rt.a C:\cpp\emsdk\upstream\emscripten\cache\wasm\libc++-noexcept.a C:\cpp\emsdk\upstream\emscripten\cache\wasm\libc++abi-noexcept.a C:\cpp\emsdk\upstream\emscripten\cache\wasm\libdlmalloc.a C:\cpp\emsdk\upstream\emscripten\cache\wasm\libc_rt_wasm.a C:\cpp\emsdk\upstream\emscripten\cache\wasm\libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --strip-debug --export-table --export main --export emscripten_stack_get_end --export emscripten_stack_get_free --export emscripten_stack_init --export stackSave --export stackRestore --export stackAlloc --export __wasm_call_ctors --export fflush --export __errno_location -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (1)
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_dff77.dir\build.make:107: cmTC_dff77.exe] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/cpp/wasmd/cmake-build-debug/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:140: cmTC_dff77/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
My toolchaint:

My Cmake options:
Code:
#include <iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
cout << "hola!" << endl;
return 0;
}
My CMakeList.txt:
# cmake_minimum_required(VERSION <specify CMake version here>)
project(wasmd)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXECUTABLE_SUFFIX .js)
add_executable(wasmd main.cpp)
Help me fix this!
请先登录再写评论。
Hello!
Emscripten compilers are not supported in CLion. Feel free to comment or upvote a related feature request: https://youtrack.jetbrains.com/issue/CPP-9434. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.