emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.98k stars 679 forks source link

undefined symbol: BIO_new_mem_buf #1234

Open assmdx opened 1 year ago

assmdx commented 1 year ago
emcc -I/usr/local/Cellar/openssl@3/3.1.0/include -L/usr/local/Cellar/openssl@3/3.1.0/lib/ -lcrypto hello.c -O3 -s WASM=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']"

log is

hello.c:25:9: warning: 'PEM_read_bio_RSA_PUBKEY' is deprecated [-Wdeprecated-declarations]
   25 |   rsa = PEM_read_bio_RSA_PUBKEY(keybio, &rsa,NULL, NULL);
      |         ^
/usr/local/Cellar/openssl@3/3.1.0/include/openssl/pem.h:452:21: note: 'PEM_read_bio_RSA_PUBKEY' has been explicitly marked deprecated here
  452 | DECLARE_PEM_rw_attr(OSSL_DEPRECATEDIN_3_0, RSA_PUBKEY, RSA)
      |                     ^
/usr/local/Cellar/openssl@3/3.1.0/include/openssl/macros.h:193:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
  193 | #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
      |                                                 ^
/usr/local/Cellar/openssl@3/3.1.0/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
   62 | #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
      |                                                    ^
hello.c:26:16: warning: 'RSA_public_encrypt' is deprecated [-Wdeprecated-declarations]
   26 |   int result = RSA_public_encrypt(data_len, data, encrypted, rsa, RSA_PKCS1_PADDING);
      |                ^
/usr/local/Cellar/openssl@3/3.1.0/include/openssl/rsa.h:287:1: note: 'RSA_public_encrypt' has been explicitly marked deprecated here
  287 | OSSL_DEPRECATEDIN_3_0
      | ^
/usr/local/Cellar/openssl@3/3.1.0/include/openssl/macros.h:193:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
  193 | #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
      |                                                 ^
/usr/local/Cellar/openssl@3/3.1.0/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
   62 | #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
      |                                                    ^
3 warnings generated.
emcc: warning: /usr/local/Cellar/openssl@3/3.1.0/lib/libcrypto.a: archive is missing an index; Use emar when creating libraries to ensure an index is created [-Wemcc]
emcc: warning: /usr/local/Cellar/openssl@3/3.1.0/lib/libcrypto.a: adding index [-Wemcc]
wasm-ld: error: /var/folders/c4/s3ktt1f11717kzxmpc_b4c_w0000gn/T/emscripten_temp_0qr9f6k6/hello_0.o: undefined symbol: BIO_new_mem_buf
wasm-ld: error: /var/folders/c4/s3ktt1f11717kzxmpc_b4c_w0000gn/T/emscripten_temp_0qr9f6k6/hello_0.o: undefined symbol: PEM_read_bio_RSA_PUBKEY
wasm-ld: error: /var/folders/c4/s3ktt1f11717kzxmpc_b4c_w0000gn/T/emscripten_temp_0qr9f6k6/hello_0.o: undefined symbol: RSA_public_encrypt
emcc: error: '/Users/assmdx/emsdk/upstream/bin/wasm-ld -o a.out.wasm -L/usr/local/Cellar/openssl@3/3.1.0/lib/ /usr/local/Cellar/openssl@3/3.1.0/lib/libcrypto.a /var/folders/c4/s3ktt1f11717kzxmpc_b4c_w0000gn/T/emscripten_temp_0qr9f6k6/hello_0.o -L/Users/assmdx/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /var/folders/c4/s3ktt1f11717kzxmpc_b4c_w0000gn/T/tmp9ttv5ax6libemscripten_js_symbols.so --strip-debug --export-if-defined=main --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=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (returned 1)
assmdx commented 1 year ago

g++ compile is success,however emsdk compile failed

MohitS05 commented 1 year ago

These are linker errors. The APIs/Symbols being mentioned like RSA_public_encrypt and PEM_read_bio_RSA_PUBKEY have been deprecated in OpenSSL 3.0. I am not sure about BIO_new_mem_buf. You can read more about it on PEM_read_bio_RSA_PUBKEYand PEM_read_bio_RSA_PUBKEY

assmdx commented 1 year ago

These are linker errors. The APIs/Symbols being mentioned like RSA_public_encrypt and PEM_read_bio_RSA_PUBKEY have been deprecated in OpenSSL 3.0. I am not sure about BIO_new_mem_buf. You can read more about it on PEM_read_bio_RSA_PUBKEYand PEM_read_bio_RSA_PUBKEY

this is because i need to compile openssl source code on Mac first, how ever I got another stuck problem when use emmake make -j 12 build_generated libssl.a libcrypto.a, the error likes this:

cc  -I. -Iinclude  -DAES_ASM -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-3\"" -DMODULESDIR="\"/usr/local/lib/ossl-modules\"" -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -DCMAKE_TOOLCHAIN_FILE=/Users/assmdx/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/Users/assmdx/emsdk/node/15.14.0_64bit/bin/node;--experimental-wasm-bulk-memory;--experimental-wasm-threads -MMD -MF ssl/libssl-lib-ssl_ciph.d.tmp -MT ssl/libssl-lib-ssl_ciph.o -c -o ssl/libssl-lib-ssl_ciph.o ssl/ssl_ciph.c
clangclangclang: clang: : clang: clangclang: : error: no input files
error: error: no input files
: error: no input fileserror: error:
no input files
no input filesclang
: error: clangno input filesno input files

: error: no input files
error: no input files
clang: error: no input files
clangclang: : error: error: no input files
no input files
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-bulk-memory: command not found
/bin/sh: --experimental-wasm-threads: command not found
make: *** [ssl/libssl-lib-ssl_cert.o] Error 127
make: *** Waiting for unfinished jobs....
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-threads: command not found
make: *** [ssl/libssl-lib-d1_msg.o] Error 127
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-threads: command not found
make: *** [ssl/libssl-lib-s3_msg.o] Error 127
make: *** [ssl/libssl-lib-pqueue.o] Error 127
make: *** [ssl/libssl-lib-d1_srtp.o] Error 127
make: *** [ssl/libssl-lib-d1_lib.o] Error 127
make: *** [ssl/libssl-lib-s3_enc.o] Error 127
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-threads: command not found
/bin/sh: --experimental-wasm-threads: command not found
make: *** [ssl/libssl-lib-s3_lib.o] Error 127
/bin/sh: --experimental-wasm-threads: command not found
make: *** [ssl/libssl-lib-methods.o] Error 127
make: *** [ssl/libssl-lib-ssl_asn1.o] Error 127
make: *** [ssl/libssl-lib-bio_ssl.o] Error 127
make: *** [ssl/libssl-lib-ssl_ciph.o] Error 127
emmake: error: 'make -j 12 build_generated libssl.a libcrypto.a' failed (returned 2)
sbc100 commented 1 year ago

Something is very wrong there. -DCMAKE_CROSSCOMPILING_EMULATOR and -DCMAKE_TOOLCHAIN_FILE are argument for cmake, and should not be passed to the compiler like that.