emscripten-core / emscripten-core/emscripten
undefined symbol: gethostbyname
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Please include the following in your bug report:
**Version of emscripten/emsdk:**
Please include the output `emcc -v` here
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.7 (48a16209b1a0de5efd8112ce6430415730008d18)
clang version 15.0.0 (https://github.com/llvm/llvm-project fbce4a78035c32792b0a13cf1f169048b822c06b)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: E:\github\emsdk\upstream\bin
**Failing command line in full:**
**Full link command and output with `-v` appended:**
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 'E:/github/emsdk/upstream/bin\wasm-ld.exe -o main.wasm CMakeFiles/main.dir/main.cxx.o -LE:\github\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten E:\github\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\crtbegin.o -lGL-mt -lal -lhtml5 -lstubs -lnoexit -lc-mt -ldlmalloc-mt -lcompiler_rt-mt -lc++-mt-noexcept -lc++abi-mt-noexcept -lsockets_proxy-mt -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined-file=C:\Users\wangjialiang\AppData\Local\Temp\tmpjtqarq58.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=emscripten_current_thread_process_queued_calls --export-if-defined=pthread_self --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export=emscripten_dispatch_to_thread_ --export=_emscripten_thread_free_data --export=_emscripten_allow_main_runtime_queued_calls --export=emscripten_main_browser_thread_id --export=emscripten_main_thread_process_queued_calls --export=emscripten_run_in_main_runtime_thread_js --export=emscripten_stack_set_limits --export=emscripten_sync_run_in_main_thread_2 --export=emscripten_sync_run_in_main_thread_4 --export=emscripten_builtin_memalign --export=emscripten_proxy_main --export=malloc --export=free --export=htons --export-table -z stack-size=5242880 --initial-memory=536870912 --entry=main --max-memory=4294967296 --global-base=1024' failed (returned 1) E:\test\wasm\socket\out\build\wasm\socket E:\test\wasm\socket\out\build\wasm\em++ 1
Just Code:
```
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set(COMPILE_OUT "WASM")
set(CMAKE_TOOLCHAIN_FILE /github/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)
project(Test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=512MB -s MAXIMUM_MEMORY=4GB -lwebsocket.js -lsyscall.js -s PROXY_POSIX_SOCKETS=1 -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s LLD_REPORT_UNDEFINED")
#find_package(DCMTK)
#include_directories(/home/wjl/github/dcmtk-3.6.6/build_wasm/install/include)
#include_directories(/svn/webgl/webgl_31/third_party/wasm/dcmtk-3.6.6/include)
#link_directories(/svn/webgl/webgl_31/third_party/wasm/dcmtk-3.6.6/lib)
add_executable(main main.cxx)
#target_link_libraries(main dcmnet dcmdata ofstd oflog z)
set_target_properties(main PROPERTIES SUFFIX ".html")
```
```
#include
#include
#include
int main() {
hostent* result = gethostbyname("www.baidu.com");
printf("result %s\n", result->h_name);
printf("end \n");
return 1;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.