Closed oatgnauh closed 7 months ago
By the way, I fix this error by giving an empty implement of clone library-xx.js
mergeInto(LibraryManager.library, {
clone: function(fn, stack, flags, arg, ext) {
console.warn("not support clone on web!!")
},
// end of custom
});
passing --js-library pathto/library-xx.js
to CMAKE_CXX_FLAGS
Since we don't need it, and never using it
Release 1.11.0 is pretty old. Does it work in the latest version?
Closing due to no response to the question about the version. Please re-open if this is still and issue.
Describe the issue
I am tring to compile gtest source code using emscripten to get wasm code. But I get a link error:
[ 20%] Built target gtest [ 30%] Linking CXX executable testgtest.js em++: warning: -pthread + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271 [-Wpthreads-mem-growth] wasm-ld: error: lib/libgtest.a(gtest-all.cc.o): undefined symbol: clone em++: error: '/media/compiler/harddisk/emsdk/upstream/bin/wasm-ld -o testgtest.wasm CMakeFiles/testgtest.dir/main.cpp.o lib/libgtest.a -L/media/compiler/harddisk/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten /media/compiler/harddisk/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/crtbegin.o -lGL-mt -lal -lhtml5 -lstubs-debug -lnoexit -lc-mt-debug -ldlmalloc-mt -lcompiler_rt-mt -lc++-mt-noexcept -lc++abi-debug-mt-noexcept -lsockets-mt -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined-file=/tmp/tmp8cg2r8bb.undefined --import-memory --shared-memory --strip-debug --export-if-defined=main --export-if-defined=_emscripten_thread_init --export-if-defined=_emscripten_thread_exit --export-if-defined=_emscripten_thread_crashed --export-if-defined=_emscripten_tls_init --export-if-defined=pthread_self --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=fflush --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=emscripten_dispatch_to_thread_ --export=_emscripten_thread_free_data --export=emscripten_main_runtime_thread_id --export=emscripten_main_thread_process_queued_calls --export=_emscripten_run_in_main_runtime_thread_js --export=emscripten_stack_set_limits --export=__get_temp_ret --export=__set_temp_ret --export=malloc --export=free --export=__wasm_call_ctors --export=ntohs --export=htons --export=htonl --export=__cxa_is_pointer_type --export=__cxa_free_exception --export=__cxa_can_catch --export=setTempRet0 --export=emscripten_builtin_memalign --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=2147483648 --stack-first' failed (returned 1) make[2]: *** [CMakeFiles/testgtest.dir/build.make:88:testgtest.js] 错误 1 make[1]: *** [CMakeFiles/Makefile2:138:CMakeFiles/testgtest.dir/all] 错误 2 make: *** [Makefile:130:all] 错误 2 emmake: error: 'make' failed (returned 2)
which indicate thatclone
function is undefinedSince I don't need process clone, and also process clone is not support by emscripten, I believe it is a good choice to remove the related code calls
clone
in Web platform. Which under macro define__wasm__
Steps to reproduce the problem
here is my CMakeLists.txt.
main.cpp
you have to install emsdk to compile this.here I am using emsdk 3.1.34
What version of GoogleTest are you using?
Release 1.11.0
What operating system and version are you using?
Linux rubbish 5.15.0-91-generic #101~20.04.1-Ubuntu SMP Thu Nov 16 14:22:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
What compiler and version are you using?
emsdk 3.1.34, which including clang.
What build system are you using?
cmake version 3.16.3
Additional context
No response