emscripten
emscripten copied to clipboard
Some errors happend when cmake build about "wasm-ld: error: unable to find library -lws2_32;"
- I ask for your help with this problem,
- In Win 10 CMD , we run "emcc -v":
D:\2Webassembly\Cinewaresdk\em22222\examples>emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.10 (c3fe57af0504fe24fc4ba697feb8c204f3c80022)
clang version 15.0.0 (https://github.com/llvm/llvm-project 8bc29d14273b05b05d5a56e34c07948dc2c770d3)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: D:\2Webassembly\emsdk\upstream\bin
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Then, we run commands as "https://badlydrawnrod.github.io/posts/2020/05/19/emcmake-with-emscripten/", but we failed * * * because of some errors as follow:
$ wasm-ld: error: unable to find library -lws2_32
$ wasm-ld: error: unable to find library -lwinmm
- The specific execution process is:
D:\2Webassembly\Cinewaresdk\em22222\examples>cmake --build cmake-build-222
[ 50%] Linking CXX executable commandline.js
wasm-ld: error: unable to find library -lws2_32
wasm-ld: error: unable to find library -lwinmm
em++: error: 'D:/2Webassembly/emsdk/upstream/bin\wasm-ld.exe -o commandline.wasm CMakeFiles/commandline.dir/source/C4DImportExport.cpp.o -lws2_32 -lwinmm -LD:\2Webassembly\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten -lGL -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__stdio_exit --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (returned 1)
mingw32-make.exe[2]: *** [commandline\CMakeFiles\commandline.dir\build.make:86: commandline/commandline.js] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:90: commandline/CMakeFiles/commandline.dir/all] Error 2
mingw32-make.exe: *** [Makefile:83: all] Error 2
The ws2_32
and winmm
looks like windows-specific libraries so should not be added the link line when building with emscripten.
I would take a look at your CMakeList.txt
files(s) and see where they are added.
@sbc100, thank you for some suggestions. There is a CMakeLists.txt in "D:\2Webassembly\Cinewaresdk\em22222\examples" CMakeLists.txt And there is a CMakeLists.txt in the subdirextory "D:\2Webassembly\Cinewaresdk\em22222\examples\commandline". CMakeLists.txt
I wonder if it will help fix this error
我也遇到了相同的问题,是否解决了呢