问:
How to correctly statically link libcurl on Windows using Clang? (64bit)
Recently, for many reasons, I switched on Windows from GCC to Clang and I want to use libcurl in a simple program, but I feel there is no guide how to setup Clang for that.
I use

clang++ -static -DCURL_STATICLIB curl-7.64.1-win64-mingw/lib/libcurl.a http-post.cpp -std=c++17 -g -Xclang -flto-visibility-public-std -o trading.exe

in VSCode and I don't even want to use Make or CMake since it's simple program.

With that command I get:

```libcurl.a(formdata.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function Curl_getformdata
libcurl.a(setopt.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function vsetopt
libcurl.a(url.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function Curl_builtin_scheme
libcurl.a(cookie.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function Curl_cookie_init
libcurl.a(mprintf.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function dprintf_formatf
libcurl.a(inet_ntop.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(strtoofft.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(parsedate.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(strerror.o) : warning LNK4217: locally defined symbol _errno imported in function Curl_strerror
libcurl.a(asyn-thread.o) : warning LNK4217: locally defined symbol _errno imported in function Curl_resolver_cancel
libcurl.a(connect.o) : warning LNK4217: locally defined symbol _errno imported in function Curl_is_connected
libcurl.a(inet_pton.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(strerror.o) : warning LNK4217: locally defined symbol _sys_nerr imported in function Curl_strerror
libcurl.a(hostip.o) : warning LNK4217: locally defined symbol tolower imported in function fetch_addr
libcurl.a(url.o) : warning LNK4217: locally defined symbol tolower imported in function Curl_freeset
libcurl.a(urlapi.o) : warning LNK4217: locally defined symbol tolower imported in function parseurl
libcurl.a(x509asn1.o) : warning LNK4217: locally defined symbol isupper imported in function ASN1tostr
libcurl.a(easy.o) : error LNK2019: unresolved external symbol strdup referenced in function global_init
libcurl.a(easy.o) : error LNK2019: unresolved external symbol libssh2_init referenced in function global_init
libcurl.a(easy.o) : error LNK2019: unresolved external symbol libssh2_exit referenced in function curl_global_cleanup
libcurl.a(system_win32.o) : error LNK2019: unresolved external symbol __imp_WSAStartup referenced in function Curl_win32_init
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_WSAStartup
libcurl.a(system_win32.o) : error LNK2019: unresolved external symbol __imp_WSACleanup referenced in function Curl_win32_init
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_WSACleanup
libcurl.a(tftp.o) : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function tftp_disconnect
libcurl.a(openssl.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(schannel.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(asyn-thread.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(select.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(sendf.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(hostip6.o) : error LNK2019: unresolved external symbol __imp_socket referenced in function Curl_ipv6works
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_socket
libcurl.a(select.o) : error LNK2019: unresolved external symbol __imp_WSASetLastError referenced in function Curl_wait_ms
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_WSASetLastError
libcurl.a(curl_addrinfo.o) : error LNK2001: unresolved external symbol __imp_WSASetLastError
libcurl.a(select.o) : error LNK2019: unresolved external symbol __imp_select referenced in function Curl_socket_check
libcurl.a(select.o) : error LNK2019: unresolved external symbol __WSAFDIsSet referenced in function Curl_socket_check
libcurl.a(version.o) : error LNK2019: unresolved external symbol zlibVersion referenced in function curl_version
libcurl.a(content_encoding.o) : error LNK2001: unresolved external symbol zlibVersion
libcurl.a(version.o) : error LNK2019: unresolved external symbol BrotliDecoderVersion referenced in function curl_version
libcurl.a(version.o) : error LNK2019: unresolved external symbol libssh2_version referenced in function curl_version
libcurl.a(tftp.o) : error LNK2019: unresolved external symbol __imp__time64 referenced in function tftp_done
libcurl.a(hostip.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(cookie.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(http.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(rtsp.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(parsedate.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(http.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(imap.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(hostip.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(cookie.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(urlapi.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(http_proxy.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(sendf.o) : error LNK2019: unresolved external symbol __imp_recv referenced in function Curl_send_plain
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_recv
libcurl.a(openssl.o) : error LNK2001: unresolved external symbol __imp_recv
libcurl.a(sendf.o) : error LNK2019: unresolved external symbol __imp_send referenced in function Curl_send_plain
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_send
libcurl.a(mime.o) : error LNK2019: unresolved external symbol __imp__stat64 referenced in function curl_mime_data
libcurl.a(mime.o) : error LNK2019: unresolved external symbol access referenced in function curl_mime_data
libcurl.a(ssh.o) : error LNK2001: unresolved external symbol access
libcurl.a(warnless.o) : error LNK2019: unresolved external symbol read referenced in function curlx_read
libcurl.a(warnless.o) : error LNK2019: unresolved external symbol write referenced in function curlx_write
libcurl.a(cookie.o) : error LNK2019: unresolved external symbol ___chkstk_ms referenced in function Curl_cookie_add
libcurl.a(mprintf.o) : error LNK2001: unresolved external symbol ___chkstk_ms
libcurl.a(netrc.o) : error LNK2001: unresolved external symbol ___chkstk_ms
libcurl.a(formdata.o) : error LNK2001: unresolved external symbol ___chkstk_ms
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_getpeername referenced in function Curl_updateconninfo
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_getsockname referenced in function Curl_updateconninfo
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_getsockname
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_ntohs referenced in function getaddressinfo
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_ntohs
libcurl.a(socks_sspi.o) : error LNK2001: unresolved external symbol __imp_ntohs
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_getsockopt referenced in function Curl_is_connected
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_closesocket referenced in function Curl_closesocket
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_setsockopt referenced in function Curl_sndbufset
libcurl.a(transfer.o) : error LNK2001: unresolved external symbol __imp_setsockopt
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_WSAIoctl referenced in function Curl_connecthost
libcurl.a(transfer.o) : error LNK2001: unresolved external symbol __imp_WSAIoctl
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(smb.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(socks_sspi.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(curl_addrinfo.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(doh.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_bind referenced in function Curl_connecthost
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_bind
libcurl.a(tftp.o) : error LNK2001: unresolved external symbol __imp_bind
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_connect referenced in function Curl_connecthost
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_version referenced in function Curl_http2_ver
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_rst_stream referenced in function Curl_http2_done
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_send referenced in function Curl_http2_done
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_set_stream_user_data referenced in function Curl_http2_done
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_pack_settings_payload referenced in function Curl_http2_request_upgrade
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_resume_data referenced in function Curl_http2_done_sending
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_mem_recv referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_strerror referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_priority_spec_init referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_priority referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_want_read referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_want_write referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_new referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_send_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_frame_recv_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_data_chunk_recv_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_stream_close_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_begin_headers_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_header_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_error_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_client_new referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_del referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_upgrade referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_settings referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_set_local_window_size referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_is_fatal referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_request referenced in function http2_send
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_del referenced in function http2_disconnect
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_ping referenced in function http2_conncheck
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_get_stream_user_data referenced in function http2_conncheck
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_get_remote_settings referenced in function http2_conncheck
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_http2_strerror referenced in function http2_conncheck
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflateInit_ referenced in function deflate_init_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflateEnd referenced in function deflate_unencode_write
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflate referenced in function deflate_close_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflateInit2_ referenced in function deflate_close_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderCreateInstance referenced in function brotli_init_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderDecompressStream referenced in function brotli_unencode_write
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderDestroyInstance referenced in function brotli_unencode_write
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderGetErrorCode referenced in function brotli_unencode_write
libcurl.a(mprintf.o) : error LNK2019: unresolved external symbol sprintf referenced in function dprintf_formatf
libcurl.a(md5.o) : error LNK2019: unresolved external symbol MD5_Init referenced in function Curl_md5it
libcurl.a(md5.o) : error LNK2019: unresolved external symbol MD5_Update referenced in function Curl_md5it
libcurl.a(md5.o) : error LNK2019: unresolved external symbol MD5_Final referenced in function Curl_md5it
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OPENSSL_load_builtin_modules referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_load_builtin_engines referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol CONF_modules_load_file referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol CRYPTO_get_ex_new_index referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OpenSSL_version_num referenced in function Curl_ossl_version
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_shutdown referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_clear_error referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_read referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_error referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_get_error referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_error_string_n referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_free referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_pending referenced in function Curl_ossl_data_pending
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_status referenced in function Curl_ossl_random
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_bytes referenced in function Curl_ossl_random
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_set_connect_state referenced in function Curl_ossl_close
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_free referenced in function Curl_ossl_close
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_finish referenced in function Curl_ossl_close_all
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_free referenced in function Curl_ossl_close_all
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_SESSION_free referenced in function Curl_ossl_session_free
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_by_id referenced in function Curl_ossl_set_engine
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_init referenced in function Curl_ossl_set_engine
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_set_default referenced in function Curl_ossl_set_engine_default
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_get_id referenced in function Curl_ossl_set_engine_default
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_get_first referenced in function Curl_ossl_engines_list
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_get_next referenced in function Curl_ossl_engines_list
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_MD_CTX_new referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_md5 referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_DigestInit_ex referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_DigestUpdate referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_DigestFinal_ex referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_MD_CTX_free referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_sha256 referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_load_file referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_add referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_file_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_connect referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_version referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_current_cipher referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CIPHER_get_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get0_alpn_selected referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_verify_result referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_verify_cert_error_string referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol TLS_client_method referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_new referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_ctrl referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_msg_callback referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_peek_error referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_s_mem referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_new referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_peer_cert_chain referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OPENSSL_sk_num referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OPENSSL_sk_value referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_subject_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_NAME_print_ex referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_ctrl referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_issuer_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_version referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_printf referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_serialNumber referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_puts referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_new referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_signature referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_signature_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_free referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol i2a_ASN1_OBJECT referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_extensions referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_EXTENSION_get_object referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol i2t_ASN1_OBJECT referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509V3_EXT_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_EXTENSION_get_data referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_free referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_notBefore referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_TIME_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_notAfter referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_pubkey referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_id referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_get0_RSA referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RSA_get0_key referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BN_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_get0_DSA referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DSA_get0_pqg referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DSA_get0_key referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_get0_DH referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DH_get0_pqg referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DH_get0_key referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_free referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol PEM_write_bio_X509 referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_peer_certificate referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_ext_d2i referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_get0_data referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_length referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_options referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_next_proto_select_cb referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_alpn_protos referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_default_passwd_cb_userdata referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_default_passwd_cb referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_use_certificate_file referenced in function Curl_ossl_sha256sum
```

<p>..</p>

```trading.exe : fatal error LNK1120: 376 unresolved externals
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)
The terminal process terminated with exit code: 1
```

<p>How to setup the build command correctly?
And can I use something more neat than </p>

```-std=c++17 -Xclang -flto-visibility-public-std
```

to use the newest C++ and STL functionality?

EDIT: According to https://github.com/Microsoft/vcpkg/issues/2621, I need something like Ws2_32.Lib, Wldap32.Lib and Crypt32.Lib and I somehow thought about that, but as I feel that Clang is somehow cross-platform, I thought it has it's own binaries for that functionality and it doesn't feel very neat to link those Windows libs...

EDIT2: Especially when I link libcurl.a, not .lib.

EDIT3: It is missing strdup anyway, which is POSIX, so I am not sure if should I use a link flag or include a file having definition of that function etc...

答:
The option -static means to produce a static library. You are obviously producing an executable. Just remove that option and it should be ok. Also you might have to put the cpp file before libcurl for link requirements.

Edit: My mistake. The -static option for gcc makes it prefer a static library when both static and shared are found for the -l option. Here you are explicitly linking with the static library. Still, the -static option is not required.

Serves me right for not reading the full output. You are missing a lot of other dependencies, e.g. WinSock, C runtime, zlib, ssl.

Body:
Recently, for many reasons, I switched on Windows from GCC to Clang and I want to use libcurl in a simple program, but I feel there is no guide how to setup Clang for that.
I use

clang++ -static -DCURL_STATICLIB curl-7.64.1-win64-mingw/lib/libcurl.a http-post.cpp -std=c++17 -g -Xclang -flto-visibility-public-std -o trading.exe

in VSCode and I don't even want to use Make or CMake since it's simple program.

With that command I get:

libcurl.a(formdata.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function Curl_getformdata
libcurl.a(setopt.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function vsetopt
libcurl.a(url.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function Curl_builtin_scheme
libcurl.a(cookie.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function Curl_cookie_init
libcurl.a(mprintf.o) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function dprintf_formatf
libcurl.a(inet_ntop.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(strtoofft.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(parsedate.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(strerror.o) : warning LNK4217: locally defined symbol _errno imported in function Curl_strerror
libcurl.a(asyn-thread.o) : warning LNK4217: locally defined symbol _errno imported in function Curl_resolver_cancel
libcurl.a(connect.o) : warning LNK4217: locally defined symbol _errno imported in function Curl_is_connected
libcurl.a(inet_pton.o) : warning LNK4049: locally defined symbol _errno imported
libcurl.a(strerror.o) : warning LNK4217: locally defined symbol _sys_nerr imported in function Curl_strerror
libcurl.a(hostip.o) : warning LNK4217: locally defined symbol tolower imported in function fetch_addr
libcurl.a(url.o) : warning LNK4217: locally defined symbol tolower imported in function Curl_freeset
libcurl.a(urlapi.o) : warning LNK4217: locally defined symbol tolower imported in function parseurl
libcurl.a(x509asn1.o) : warning LNK4217: locally defined symbol isupper imported in function ASN1tostr
libcurl.a(easy.o) : error LNK2019: unresolved external symbol strdup referenced in function global_init
libcurl.a(easy.o) : error LNK2019: unresolved external symbol libssh2_init referenced in function global_init
libcurl.a(easy.o) : error LNK2019: unresolved external symbol libssh2_exit referenced in function curl_global_cleanup
libcurl.a(system_win32.o) : error LNK2019: unresolved external symbol __imp_WSAStartup referenced in function Curl_win32_init
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_WSAStartup
libcurl.a(system_win32.o) : error LNK2019: unresolved external symbol __imp_WSACleanup referenced in function Curl_win32_init
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_WSACleanup
libcurl.a(tftp.o) : error LNK2019: unresolved external symbol __imp_WSAGetLastError referenced in function tftp_disconnect
libcurl.a(openssl.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(schannel.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(asyn-thread.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(select.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(sendf.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
libcurl.a(hostip6.o) : error LNK2019: unresolved external symbol __imp_socket referenced in function Curl_ipv6works
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_socket
libcurl.a(select.o) : error LNK2019: unresolved external symbol __imp_WSASetLastError referenced in function Curl_wait_ms
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_WSASetLastError
libcurl.a(curl_addrinfo.o) : error LNK2001: unresolved external symbol __imp_WSASetLastError
libcurl.a(select.o) : error LNK2019: unresolved external symbol __imp_select referenced in function Curl_socket_check
libcurl.a(select.o) : error LNK2019: unresolved external symbol __WSAFDIsSet referenced in function Curl_socket_check
libcurl.a(version.o) : error LNK2019: unresolved external symbol zlibVersion referenced in function curl_version
libcurl.a(content_encoding.o) : error LNK2001: unresolved external symbol zlibVersion
libcurl.a(version.o) : error LNK2019: unresolved external symbol BrotliDecoderVersion referenced in function curl_version
libcurl.a(version.o) : error LNK2019: unresolved external symbol libssh2_version referenced in function curl_version
libcurl.a(tftp.o) : error LNK2019: unresolved external symbol __imp__time64 referenced in function tftp_done
libcurl.a(hostip.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(cookie.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(http.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp__time64
libcurl.a(rtsp.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(parsedate.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(http.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(imap.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(hostip.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(cookie.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(urlapi.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(http_proxy.o) : error LNK2001: unresolved external symbol sscanf
libcurl.a(sendf.o) : error LNK2019: unresolved external symbol __imp_recv referenced in function Curl_send_plain
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_recv
libcurl.a(openssl.o) : error LNK2001: unresolved external symbol __imp_recv
libcurl.a(sendf.o) : error LNK2019: unresolved external symbol __imp_send referenced in function Curl_send_plain
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_send
libcurl.a(mime.o) : error LNK2019: unresolved external symbol __imp__stat64 referenced in function curl_mime_data
libcurl.a(mime.o) : error LNK2019: unresolved external symbol access referenced in function curl_mime_data
libcurl.a(ssh.o) : error LNK2001: unresolved external symbol access
libcurl.a(warnless.o) : error LNK2019: unresolved external symbol read referenced in function curlx_read
libcurl.a(warnless.o) : error LNK2019: unresolved external symbol write referenced in function curlx_write
libcurl.a(cookie.o) : error LNK2019: unresolved external symbol ___chkstk_ms referenced in function Curl_cookie_add
libcurl.a(mprintf.o) : error LNK2001: unresolved external symbol ___chkstk_ms
libcurl.a(netrc.o) : error LNK2001: unresolved external symbol ___chkstk_ms
libcurl.a(formdata.o) : error LNK2001: unresolved external symbol ___chkstk_ms
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_getpeername referenced in function Curl_updateconninfo
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_getsockname referenced in function Curl_updateconninfo
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_getsockname
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_ntohs referenced in function getaddressinfo
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_ntohs
libcurl.a(socks_sspi.o) : error LNK2001: unresolved external symbol __imp_ntohs
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_getsockopt referenced in function Curl_is_connected
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_closesocket referenced in function Curl_closesocket
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_setsockopt referenced in function Curl_sndbufset
libcurl.a(transfer.o) : error LNK2001: unresolved external symbol __imp_setsockopt
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_WSAIoctl referenced in function Curl_connecthost
libcurl.a(transfer.o) : error LNK2001: unresolved external symbol __imp_WSAIoctl
libcurl.a(telnet.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(smb.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(socks_sspi.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(connect.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(curl_addrinfo.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(doh.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_htons
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_bind referenced in function Curl_connecthost
libcurl.a(ftp.o) : error LNK2001: unresolved external symbol __imp_bind
libcurl.a(tftp.o) : error LNK2001: unresolved external symbol __imp_bind
libcurl.a(connect.o) : error LNK2019: unresolved external symbol __imp_connect referenced in function Curl_connecthost
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_version referenced in function Curl_http2_ver
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_rst_stream referenced in function Curl_http2_done
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_send referenced in function Curl_http2_done
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_set_stream_user_data referenced in function Curl_http2_done
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_pack_settings_payload referenced in function Curl_http2_request_upgrade
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_resume_data referenced in function Curl_http2_done_sending
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_mem_recv referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_strerror referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_priority_spec_init referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_priority referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_want_read referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_want_write referenced in function h2_process_pending_input
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_new referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_send_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_frame_recv_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_data_chunk_recv_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_stream_close_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_begin_headers_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_on_header_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_set_error_callback referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_client_new referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_callbacks_del referenced in function Curl_http2_setup
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_upgrade referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_settings referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_set_local_window_size referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_is_fatal referenced in function Curl_http2_switched
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_request referenced in function http2_send
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_del referenced in function http2_disconnect
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_submit_ping referenced in function http2_conncheck
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_get_stream_user_data referenced in function http2_conncheck
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_session_get_remote_settings referenced in function http2_conncheck
libcurl.a(http2.o) : error LNK2019: unresolved external symbol nghttp2_http2_strerror referenced in function http2_conncheck
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflateInit_ referenced in function deflate_init_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflateEnd referenced in function deflate_unencode_write
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflate referenced in function deflate_close_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol inflateInit2_ referenced in function deflate_close_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderCreateInstance referenced in function brotli_init_writer
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderDecompressStream referenced in function brotli_unencode_write
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderDestroyInstance referenced in function brotli_unencode_write
libcurl.a(content_encoding.o) : error LNK2019: unresolved external symbol BrotliDecoderGetErrorCode referenced in function brotli_unencode_write
libcurl.a(mprintf.o) : error LNK2019: unresolved external symbol sprintf referenced in function dprintf_formatf
libcurl.a(md5.o) : error LNK2019: unresolved external symbol MD5_Init referenced in function Curl_md5it
libcurl.a(md5.o) : error LNK2019: unresolved external symbol MD5_Update referenced in function Curl_md5it
libcurl.a(md5.o) : error LNK2019: unresolved external symbol MD5_Final referenced in function Curl_md5it
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OPENSSL_load_builtin_modules referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_load_builtin_engines referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol CONF_modules_load_file referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol CRYPTO_get_ex_new_index referenced in function Curl_ossl_init
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OpenSSL_version_num referenced in function Curl_ossl_version
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_shutdown referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_clear_error referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_read referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_error referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_get_error referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_error_string_n referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_free referenced in function Curl_ossl_shutdown
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_pending referenced in function Curl_ossl_data_pending
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_status referenced in function Curl_ossl_random
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_bytes referenced in function Curl_ossl_random
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_set_connect_state referenced in function Curl_ossl_close
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_free referenced in function Curl_ossl_close
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_finish referenced in function Curl_ossl_close_all
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_free referenced in function Curl_ossl_close_all
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_SESSION_free referenced in function Curl_ossl_session_free
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_by_id referenced in function Curl_ossl_set_engine
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_init referenced in function Curl_ossl_set_engine
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_set_default referenced in function Curl_ossl_set_engine_default
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_get_id referenced in function Curl_ossl_set_engine_default
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_get_first referenced in function Curl_ossl_engines_list
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ENGINE_get_next referenced in function Curl_ossl_engines_list
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_MD_CTX_new referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_md5 referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_DigestInit_ex referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_DigestUpdate referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_DigestFinal_ex referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_MD_CTX_free referenced in function Curl_ossl_md5sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_sha256 referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_load_file referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_add referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RAND_file_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_connect referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_version referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_current_cipher referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CIPHER_get_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get0_alpn_selected referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_verify_result referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_verify_cert_error_string referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol TLS_client_method referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_new referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_ctrl referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_msg_callback referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ERR_peek_error referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_s_mem referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_new referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_peer_cert_chain referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OPENSSL_sk_num referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol OPENSSL_sk_value referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_subject_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_NAME_print_ex referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_ctrl referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_issuer_name referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_version referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_printf referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_serialNumber referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_puts referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_new referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_signature referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_signature_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_free referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol i2a_ASN1_OBJECT referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_extensions referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_EXTENSION_get_object referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol i2t_ASN1_OBJECT referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509V3_EXT_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_EXTENSION_get_data referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BIO_free referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_notBefore referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_TIME_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get0_notAfter referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_pubkey referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_id referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_get0_RSA referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol RSA_get0_key referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol BN_print referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_get0_DSA referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DSA_get0_pqg referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DSA_get0_key referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_get0_DH referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DH_get0_pqg referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol DH_get0_key referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol EVP_PKEY_free referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol PEM_write_bio_X509 referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_get_peer_certificate referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol X509_get_ext_d2i referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_get0_data referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol ASN1_STRING_length referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_options referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_next_proto_select_cb referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_alpn_protos referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_default_passwd_cb_userdata referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_set_default_passwd_cb referenced in function Curl_ossl_sha256sum
libcurl.a(openssl.o) : error LNK2019: unresolved external symbol SSL_CTX_use_certificate_file referenced in function Curl_ossl_sha256sum

..

trading.exe : fatal error LNK1120: 376 unresolved externals
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)
The terminal process terminated with exit code: 1

How to setup the build command correctly?
And can I use something more neat than

-std=c++17 -Xclang -flto-visibility-public-std

to use the newest C++ and STL functionality?

EDIT: According to https://github.com/Microsoft/vcpkg/issues/2621, I need something like Ws2_32.Lib, Wldap32.Lib and Crypt32.Lib and I somehow thought about that, but as I feel that Clang is somehow cross-platform, I thought it has it's own binaries for that functionality and it doesn't feel very neat to link those Windows libs...

EDIT2: Especially when I link libcurl.a, not .lib.

EDIT3: It is missing strdup anyway, which is POSIX, so I am not sure if should I use a link flag or include a file having definition of that function etc...


来源: stackexchange

问:
I need to split a value in the variable
I need to split the path defined in below code in following a manner that </p>

```<code>k[0] = /dev/mapper/centos-root
k[1] = 52403200
k[2] = 14460252 an so on.
</code>```

<p>What have I tried?
I tried using the split function but it currently takes k[0] = /
also, I tried passing it into a list where the whole context comes as one value </p>

```<code>command = ("df -P | egrep '([20][0-9]|100)%' |  awk '{print}'|sed -e 's/ / : /g'")
command_execute = (stdin, stdout, stderr) = ssh.exec_command(command)
read_contents = stdout.read().decode("utf-8")
read_contents
'/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'
k=read_contents[0]
k
'/'
k=read_contents[1]
k
'd'
k.split(" ")
['d']
m =k.split(":")
m
['d']
s = [read_contents]
s
['/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n']
s[0]
'/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'
s[1]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
IndexError: list index out of range
s[0]
'/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'

k[0] = /dev/mapper/centos-root
k[1] = 52403200
k[2] = 14460252 an so on.
</code>```

答:
You want to get rid of strings with whitespaces when you split on :

```<code>In [20]: read_contents = '/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'
#Get rid of empty strings, and strip leading and trailing whitespaces around the rest of the words
In [21]: contents = [content.strip() for content in read_contents.split(':') if content.strip()]

In [22]: contents
Out[22]: ['/dev/mapper/centos-root', '52403200', '14460252', '37942948', '28%', '/']

In [23]: for item in contents:
    ...:     print(item)
    ...:
/dev/mapper/centos-root
52403200
14460252
37942948
28%
/
</code>```

ContentLicense: CC BY-SA 4.0

Title: I need to split a value in the variable

Body:
I need to split the path defined in below code in following a manner that

k[0] = /dev/mapper/centos-root
k[1] = 52403200
k[2] = 14460252 an so on.

What have I tried?
I tried using the split function but it currently takes k[0] = /
also, I tried passing it into a list where the whole context comes as one value

command = ("df -P | egrep '([20][0-9]|100)%' |  awk '{print}'|sed -e 's/ / : /g'")
command_execute = (stdin, stdout, stderr) = ssh.exec_command(command)
read_contents = stdout.read().decode("utf-8")
read_contents
'/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'
k=read_contents[0]
k
'/'
k=read_contents[1]
k
'd'
k.split(" ")
['d']
m =k.split(":")
m
['d']
s = [read_contents]
s
['/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n']
s[0]
'/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'
s[1]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
IndexError: list index out of range
s[0]
'/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'

k[0] = /dev/mapper/centos-root
k[1] = 52403200
k[2] = 14460252 an so on.

Body:
You want to get rid of strings with whitespaces when you split on :

In [20]: read_contents = '/dev/mapper/centos-root :  :  :  : 52403200 : 14460252 :  : 37942948 :  :  :  :  :  : 28% : /\n'
#Get rid of empty strings, and strip leading and trailing whitespaces around the rest of the words
In [21]: contents = [content.strip() for content in read_contents.split(':') if content.strip()]

In [22]: contents
Out[22]: ['/dev/mapper/centos-root', '52403200', '14460252', '37942948', '28%', '/']

In [23]: for item in contents:
    ...:     print(item)
    ...:
/dev/mapper/centos-root
52403200
14460252
37942948
28%
/


问:
Prevent viewport from moving when removing DOM elements
I'm trying to implement an HTML infinite scroller in which at any given time there are only a handful of div elements on list (to keep the memory footprint small).

I append a new div element to the list and at the same time I'm removing the first one, so the total count of divs remains the same.

Unfortunately the viewport doesn't stay still but instead it jumps backwards a little bit (the height of the removed div actually).
Is there a way to keep the viewport still while removing divs from the list?

I made a small self contained HTML page (well, it still needs JQuery 3.4.1) which exposes the problem: it starts by adding 5 divs and then it keeps adding a new one and removing the first one every 1 second

function getRandomColor() {
  var letters = '0123456789ABCDEF';
  var color = '#';
  for (var i = 0; i < 6; i++) {
    color += letters[Math.floor(Math.random() * 16)];
  }
  return color;
}

function removeit() {
  // remove first one
  var tiles = $(".tile");
  $(tiles[0]).remove();
}

function addit() {
  // append new one
  var jqueryTextElem = $('

');
  $("#inner-wrap").append(jqueryTextElem);
}

function loop() {
  removeit();

  addit();

  window.setTimeout(loop, 1000);
}

addit();
addit();
addit();
addit();
addit();

loop();```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="inner-wrap"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script></code>```

答:
You can temporarily add position: fixed to the parent element:

first add position: fixed to the parent;

then remove the item;

then remove position: fixed from the parent


问:
How to call this function?
I have a function in Saves.java class and i want to call this function in the other Import.java class, how doing it ?
Here is the code of the function:

```<code>public void updatelv(Activity activity) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String fileName = getResources().getString(R.string.fileName);
        fileDir = "" + preferences.getString("login", "") + "."+ preferences.getString("marque", "") + ".";
        list = myIO.ReadFilePerLine(getApplicationContext(), fileDir+fileName);
        ListView L = (ListView) findViewById(R.id.lv);

        ArrayAdapter adapter = new ArrayAdapter(this, R.layout.list_item, list);
        L.setAdapter(adapter);
        }
</code>```

I think that i have to do this :  Saves save=new Saves();
And after, how to call the updatelv(activity) function ?

Thank you.

the import.java class called when pressed in a menu Import" button(in Saves.java class):

```<code>case R.id.importer:
  Import myImport = new Import(this);
  myImport.transfer();
</code>```

答:
There are two ways to accomplish what you're looking for.

Option #1:

```<code>Saves save = new Saves();
save.updatelv(this);
</code>```

Option #2:

Make your updatelv() method static (most useful in a Tool class, where you have stuff that never touches the UI views):

```<code>public static void updatelv(...) {}

//...

Saves.updatelv(this);
</code>```

ContentLicense: CC BY-SA 3.0

Title: How to call this function?

Body:
I have a function in Saves.java class and i want to call this function in the other Import.java class, how doing it ?
Here is the code of the function:

public void updatelv(Activity activity) {
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String fileName = getResources().getString(R.string.fileName);
        fileDir = "" + preferences.getString("login", "") + "."+ preferences.getString("marque", "") + ".";
        list = myIO.ReadFilePerLine(getApplicationContext(), fileDir+fileName);
        ListView L = (ListView) findViewById(R.id.lv);

        ArrayAdapter adapter = new ArrayAdapter(this, R.layout.list_item, list);
        L.setAdapter(adapter);
        }

I think that i have to do this :  Saves save=new Saves();
And after, how to call the updatelv(activity) function ?

Thank you.

the import.java class called when pressed in a menu Import" button(in Saves.java class):

case R.id.importer:
  Import myImport = new Import(this);
  myImport.transfer();

Body:
There are two ways to accomplish what you're looking for.

Option #1:

Saves save = new Saves();
save.updatelv(this);

Option #2:

Make your updatelv() method static (most useful in a Tool class, where you have stuff that never touches the UI views):

public static void updatelv(...) {}

//...

Saves.updatelv(this);


问:
Update an attribute and remove duplicate element in an array from JavaScript
I've got a problem about some code.
Here's my array

[
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 1,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 2,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 1,
    numberHoursSpent: 3,
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 4,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 3,
    numberHoursSpent: 5,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  }
  ]```
</div>
</div>
</p>

<p>The problem is I need to make my array looks like this.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>[
  {
    name: "Sale Network 1",
    numberSoldLodging: 3,
    numberHoursSpent: (1+2+4)/(1+1+1),
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 2,
    numberHoursSpent: (3+5)/(1+3),
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },

  ]</code>```

which is equivalent to this

[
  {
    name: "Sale Network 1",
    numberSoldLodging: 3,
    numberHoursSpent: 2.33,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 2,
    numberHoursSpent: 2,
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },

  ]```
</div>
</div>
</p>

<p>First I find the same objects in array if they have the same "name" attributes.Then I sum all numberHoursSpent attributes and divide them by sum of numberSoldLodgings attributes from those objects.
Then I remove all the same elements, only keep an unique one.
P/S: The objects are the same if they have the same "name" attributes.
Here's what I've tried.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>handleData = arr => {
  var firstElementIndex =0;
  const final = []
  var filteredArray = []
  arr.map((e,i)=>{
    if(final.includes(e.name)){
      var k = k+arr[i].numberHoursSpent;
      firstElementIndex = final.indexOf(e.name);
      arr[firstElementIndex].numberHoursSpent +=  arr[i].numberHoursSpent
      filteredArray= arr.filter(item => item !== arr[i] )
    }
    else{
      final.push(e.name)
    }
    if(i == arr.length-1){
      arr[firstElementIndex].numberHoursSpent /= k
    }
  })

  return filteredArray;
}</code>```

Please help me, thanks.

答:
You may try out as,

let array = [{
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 1,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 2,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 1,
    numberHoursSpent: 3,
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 4,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 3,
    numberHoursSpent: 5,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  }
];

function filteredArray(array){
  let filteredArr = [];
  // Initialize the array
  filteredArr.push(array[0]);

  // Filtered the array
  for(let i=1; i<array.length; i++){
    let elementFound = false;

    for(let j=0; j<filteredArr.length; j++){
      if(array[i].name === filteredArr[j].name){
        elementFound = true;
        filteredArr[j].numberSoldLodging += array[i].numberSoldLodging;
        filteredArr[j].numberHoursSpent += array[i].numberHoursSpent;
      }
    }

    if(!elementFound)
      filteredArr.push(array[i]);
  }

  // Modified the 'numberHoursSpent'
  filteredArr.forEach(el => {
      el.numberHoursSpent /= el.numberSoldLodging;
      el.numberHoursSpent = parseFloat(el.numberHoursSpent.toFixed(2));
      });

  // Note : I have added toFixed for above long float integer '2.33333333333333333'

  return filteredArr;
}

console.log(filteredArray(array));```

Body:
I've got a problem about some code.
Here's my array

[
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 1,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 2,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 1,
    numberHoursSpent: 3,
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },
  {
    name: "Sale Network 1",
    numberSoldLodging: 1,
    numberHoursSpent: 4,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 3,
    numberHoursSpent: 5,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  }
  ]

The problem is I need to make my array looks like this.

[
  {
    name: "Sale Network 1",
    numberSoldLodging: 3,
    numberHoursSpent: (1+2+4)/(1+1+1),
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 2,
    numberHoursSpent: (3+5)/(1+3),
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },

  ]

which is equivalent to this

[
  {
    name: "Sale Network 1",
    numberSoldLodging: 3,
    numberHoursSpent: 2.33,
    mail: "lanlehoang10@gmail.com",
    id: "5ceb9b5aff2d5732b4282886",
    created: 1558944602810,
    updated: 1558944602810
  },
  {
    name: "Sale Network 2",
    numberSoldLodging: 2,
    numberHoursSpent: 2,
    mail: "sale2@gmail.com",
    id: "5cef5a62b9c3113764e2183b",
    created: 1559190114548,
    updated: 1559190114548
  },

  ]

First I find the same objects in array if they have the same "name" attributes.Then I sum all numberHoursSpent attributes and divide them by sum of numberSoldLodgings attributes from those objects.
Then I remove all the same elements, only keep an unique one.
P/S: The objects are the same if they have the same "name" attributes.
Here's what I've tried.

handleData = arr => {
  var firstElementIndex =0;
  const final = []
  var filteredArray = []
  arr.map((e,i)=>{
    if(final.includes(e.name)){
      var k = k+arr[i].numberHoursSpent;
      firstElementIndex = final.indexOf(e.name);
      arr[firstElementIndex].numberHoursSpent +=  arr[i].numberHoursSpent
      filteredArray= arr.filter(item => item !== arr[i] )
    }
    else{
      final.push(e.name)
    }
    if(i == arr.length-1){
      arr[firstElementIndex].numberHoursSpent /= k
    }
  })

  return filteredArray;
}

Please help me, thanks.


问:
How to draw a circle inside a circle using Android xml shapes?
I'm trying to make a thumb for a seekbar for my app, and I want to have an inner circle surrounded by a different, larger (semi-transparent) outer circle. I'm trying to use layer-list, but I'm having issues. Below is my code...

```<code><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape
        android:shape="oval" >
        <solid android:color="#00f" />

        <size
            android:height="15dp"
            android:width="15dp" />
    </shape>
</item>

<item>
    <shape
        android:shape="oval" >
        <solid android:color="#f00" />

        <size
            android:height="10dp"
            android:width="10dp" />
    </shape>
</item>

</layer-list>
</code>```

I would expect to see a small red circle on top of a larger blue circle, but all I'm seeing is the small red circle. Does anyone have any ideas?

答:
Just you have to use Shap Attribute

xml code drawable

```<code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
    <stroke android:width="2dp" android:color="#B91969"/>
    <size android:width="@dimen/dim_16dp" android:height="@dimen/dim_16dp" />
    <solid android:color="#0f0" />
</shape>
</code>```

Output

Body:
I'm trying to make a thumb for a seekbar for my app, and I want to have an inner circle surrounded by a different, larger (semi-transparent) outer circle. I'm trying to use layer-list, but I'm having issues. Below is my code...

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
    <shape
        android:shape="oval" >
        <solid android:color="#00f" />

        <size
            android:height="15dp"
            android:width="15dp" />
    </shape>
</item>

<item>
    <shape
        android:shape="oval" >
        <solid android:color="#f00" />

        <size
            android:height="10dp"
            android:width="10dp" />
    </shape>
</item>

</layer-list>

I would expect to see a small red circle on top of a larger blue circle, but all I'm seeing is the small red circle. Does anyone have any ideas?

Body:
Just you have to use Shap Attribute

xml code drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
    <stroke android:width="2dp" android:color="#B91969"/>
    <size android:width="@dimen/dim_16dp" android:height="@dimen/dim_16dp" />
    <solid android:color="#0f0" />
</shape>

Output


问:
SVD for image compression-image takes more disk size, hmm..?
```<code>d=50;
im = imread('H:\matlab\bildanalys\terminator.gif');
M2 = double(im);
[U S V] = svd(M2);
U2 = U(:,1:d);
S2 = S(1:d,1:d);
V2 = V(:,1:d);
compressed=U2*S2*V2';
imwrite(compressed,'H:\matlab\bildanalys\compressedterminator.gif','gif')
S2
</code>```

the compressed image is 3times bigger...

I do svd on the image, throw away the smaller singular values(although they are quite big) then multiply together the matrices again to get the compressed image. the compressed image is black and white and bigger than the original. where do i fail?

答:
I'm not sure how you end up with 3 times bigger, as conversions between classes scale in powers of 2. The only explanation I can think of is that the original image, im was probably a uint8 with 3 color channels. This upon conversion to grayscale and double, becomes 8/3~2.67 times as big. However, it doesn't look like you're going from 3 dims to 1, unless if you didn't post that part of the code here.

As for using SVDs to reduce storage, if you re-multiply your matrices, you're going back to a full matrix with the exact same number of elements as you started with and hence you'll get the same sized image.

Body:
d=50;
im = imread('H:\matlab\bildanalys\terminator.gif');
M2 = double(im);
[U S V] = svd(M2);
U2 = U(:,1:d);
S2 = S(1:d,1:d);
V2 = V(:,1:d);
compressed=U2*S2*V2';
imwrite(compressed,'H:\matlab\bildanalys\compressedterminator.gif','gif')
S2

the compressed image is 3times bigger...

I do svd on the image, throw away the smaller singular values(although they are quite big) then multiply together the matrices again to get the compressed image. the compressed image is black and white and bigger than the original. where do i fail?


问:
Why use spring.factories for Spring Boot auto-configuration instead of annotations?
The documentation states:

Developing auto-configuration and using conditions

If you work in a company that develops shared libraries, or if you work on an open-source or commercial library, you might want to develop your own auto-configuration. Auto-configuration classes can be bundled in external jars and still be picked-up by Spring Boot.

If I have annotations for everything else (even  @AutoConfigureAfter or @AutoConfigureBefore annotations),

Why maintain a properties file to point to a class with an annotation?

答:
When SpringBoot app is starting, it will not scan all the classes in jars, So SpringBoot starter should specify which classes are auto-configured. For example, in spring-boot-2.0.4.RELEASE, it initializes like this:

@SpringBootApplication
public class MyApplication {
    public static void main(String[] args) {
       //1. method run will call the construtor below
        SpringApplication.run(MyApplication.class, args);
    }
}

    public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
        this.resourceLoader = resourceLoader;
        Assert.notNull(primarySources, "PrimarySources must not be null");
        this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
        this.webApplicationType = deduceWebApplicationType();
        //2. find all the classes whose key is ApplicationContextInitializer in spring.factories and initialize them
        setInitializers((Collection) getSpringFactoriesInstances(
                ApplicationContextInitializer.class));
        setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
        this.mainApplicationClass = deduceMainApplicationClass();
    }

...
    private <T> Collection<T> getSpringFactoriesInstances(Class<T> type,
            Class<?>[] parameterTypes, Object... args) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        // Use names and ensure unique to protect against duplicates
        Set<String> names = new LinkedHashSet<>(
                //3. use current thread classcloader to load resources in the classpath
                SpringFactoriesLoader.loadFactoryNames(type, classLoader));
        List<T> instances = createSpringFactoriesInstances(type, parameterTypes,
                classLoader, args, names);
        AnnotationAwareOrderComparator.sort(instances);
        return instances;
    }

//SpringFactoriesLoader.java
public static List<String> loadFactoryNames(Class<?> factoryClass, @Nullable ClassLoader classLoader) {
        String factoryClassName = factoryClass.getName();
        // 3.1  first find the configuration file
        return loadSpringFactories(classLoader).getOrDefault(factoryClassName, Collections.emptyList());
    }

private static Map<String, List<String>> loadSpringFactories(@Nullable ClassLoader classLoader) {
        ...
        try {
            Enumeration<URL> urls = (classLoader != null ?
            //  public static final String FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories";
            //4. spring.factories file is defined here
                    classLoader.getResources(FACTORIES_RESOURCE_LOCATION) :
                    ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));
            result = new LinkedMultiValueMap<>();
            ...
    }
```


问:
from jquery scope call to class function
I want to call from Jquery scope (which is in the same class) to same class function/method. How I should do?

I tried:

displayTemplate.findWithAttr(action);

or

this.findWithAttr(action);

Response

"this.findWithAttr is not a function"

Here is my code.

```<code>class displayTemplate{
  findWithAttr(action) {
    //to do something with action
  }
  router(action){
    if(action == "something"){
      $( "#confirm_dialog_msg" ).text("text?");
         $( "#dialog-confirm" ).dialog({
           buttons: {
             "yes": function() {
                $( this ).dialog( "close" );

               //how in this area call to "findWithAttr" function above?
                this.findWithAttr(action);

             },
             "No": function() {
               //..
             }
           }
        });
      }
  //...
  }
}
</code>```

答:
Before you enter the JQuery scope of the function, declare a variable like this

```<code>var self = this;
</code>```

And then just do self.findWithAttr and that should work.

So like:

```<code>router(action){
if(action == "something"){
  var self = this;
  $( "#confirm_dialog_msg" ).text("text?");
     $( "#dialog-confirm" ).dialog({
       buttons: {
         "yes": function() {
            $( this ).dialog( "close" );

           //how in this area call to "findWithAttr" function above?
            self.findWithAttr(action);

         },
         "No": function() {
           //..
         }
       }
    });
  }
</code>```

Hope this helped.

Body:
I want to call from Jquery scope (which is in the same class) to same class function/method. How I should do?

I tried:

displayTemplate.findWithAttr(action);

or

this.findWithAttr(action);

Response

"this.findWithAttr is not a function"

Here is my code.

class displayTemplate{
  findWithAttr(action) {
    //to do something with action
  }
  router(action){
    if(action == "something"){
      $( "#confirm_dialog_msg" ).text("text?");
         $( "#dialog-confirm" ).dialog({
           buttons: {
             "yes": function() {
                $( this ).dialog( "close" );

               //how in this area call to "findWithAttr" function above?
                this.findWithAttr(action);

             },
             "No": function() {
               //..
             }
           }
        });
      }
  //...
  }
}

Body:
Before you enter the JQuery scope of the function, declare a variable like this

var self = this;

And then just do self.findWithAttr and that should work.

So like:

router(action){
if(action == "something"){
  var self = this;
  $( "#confirm_dialog_msg" ).text("text?");
     $( "#dialog-confirm" ).dialog({
       buttons: {
         "yes": function() {
            $( this ).dialog( "close" );

           //how in this area call to "findWithAttr" function above?
            self.findWithAttr(action);

         },
         "No": function() {
           //..
         }
       }
    });
  }

Hope this helped.


问:
Request from Firebase Hosting to Firebase Function blocked by CORS
I'm trying to send push notifications between two devices for a tiny prototype. Both of them are Vue.js apps with firebase SDK integrated, so to implement a push notification flow I deployed a firebase function, but when I call it from any of devices, a CORS error is received as a response.

Both devices (mobile and desktop) have the same client code and knows the token of each other (storage into a firebase real-time database).
The function only uses firebase messaging to send the push notification.

Firebase function:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({ origin: true });

admin.initializeApp();

exports.notification = functions.https.onRequest((req, res) => {
    return cors(req, res, () => {
        if (req.method === "POST") {
            return admin.messaging().send(notification)
                .then(result => {
                    console.log(result);
                    res.status(200).send("ok")
                })
                .catch(err => res.status(500).send(err));
        } else {
            return res.status(400).send("Method not allowed");
        }
    });
});
```

<p>Client code:</p>

<pre class="lang-js prettyprint-override"><code>send(notification, token) {
    return fetch("https://[zone]-[project].cloudfunctions.net/notifications", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ token, notification })
    });
}

</code>```

And the error is:

```<code>Access to fetch at 'https://[zone]-[project].cloudfunctions.net/notifications' from origin 'https://[project].web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
</code>```

答: The URI that I used to invoke the function was wrong. It's solved. Sorry about that question.</p>

Body:
I'm trying to send push notifications between two devices for a tiny prototype. Both of them are Vue.js apps with firebase SDK integrated, so to implement a push notification flow I deployed a firebase function, but when I call it from any of devices, a CORS error is received as a response.

Both devices (mobile and desktop) have the same client code and knows the token of each other (storage into a firebase real-time database).
The function only uses firebase messaging to send the push notification.

Firebase function:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({ origin: true });

admin.initializeApp();

exports.notification = functions.https.onRequest((req, res) => {
    return cors(req, res, () => {
        if (req.method === "POST") {
            return admin.messaging().send(notification)
                .then(result => {
                    console.log(result);
                    res.status(200).send("ok")
                })
                .catch(err => res.status(500).send(err));
        } else {
            return res.status(400).send("Method not allowed");
        }
    });
});

Client code:

send(notification, token) {
    return fetch("https://[zone]-[project].cloudfunctions.net/notifications", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ token, notification })
    });
}

And the error is:

Access to fetch at 'https://[zone]-[project].cloudfunctions.net/notifications' from origin 'https://[project].web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.


问:
How to copy worksheets with renaming as per list?
I am trying the below code, to copy a 'master' worksheet with renaming as per values in worksheet 'List', which is working only once.

If I try to run the macro again renaming does not happen.

runtime Error '1004':

  name is already taken . try a different one

The macro should work one loop and end. When rerun the macro should jump to the next value in the 'List'.

```<code>Private Sub CommandButton1_Click()
Dim i As Integer
Dim ws As Worksheet
Dim sh As Worksheet
Set ws = Sheets("Master")
Set sh = Sheets("List")
Application.ScreenUpdating = 0
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
    Application.CopyObjectsWithCells = False
    Sheets("Master").Copy After:=sh
    Application.CopyObjectsWithCells = True
    ActiveSheet.Name = sh.Range("A" & i).Value
    ActiveSheet.Range("F3").Value = sh.Range("A" & i).Value
Exit For
Next i
ws.Activate
End Sub
</code>```

答:
You were missing some info to tell the VBA code to loop if the current name (sh.Range("A" & i).value) was already taken by a worksheet.

Following is what I have come up with:

```<code>Private Sub CommandButton1_Click()
    Dim i As Integer
    Dim ws As Worksheet
    Dim sh As Worksheet

    Dim tmpWS As Worksheet 'will be used to test whether a worksheet already exists

    Set ws = Sheets("Master")
    Set sh = Sheets("List")

    'storing the last row I think is better as well as using explicit
    'definition of the range (sh.Range rather then Range alone)
    Dim lastRow As Integer
    lastRow = sh.Range("A" & Rows.Count).End(xlUp).Row

    Application.ScreenUpdating = False

    For i = 1 To lastRow

        'trying to set a worksheet variable with the new name from the list
        'if the result returns a set variable (variable not returning "Nothing")
        'it means the worksheet exists
        On Error Resume Next '--> will continue even if it encounters an error.  Don't overuse this
        Set tmpWS = ThisWorkbook.Worksheets(sh.Range("a" & i).Value2)
        On Error GoTo 0 '--> will set back default error handling.  From now on, the "Resume Next" is disabled.

        'this is true if worksheet named "sh.Range("A" & i).Value" does not exist
        If (tmpWS Is Nothing) Then

            Excel.Application.CopyObjectsWithCells = False
            Sheets("Master").Copy After:=sh
            ActiveSheet.Name = sh.Range("A" & i).Value
            ActiveSheet.Range("F3").Value = sh.Range("A" & i).Value
            Excel.Application.CopyObjectsWithCells = True
            Exit For

        Else

            'force tmpWS to be set to nothing prior making another run in the loop
            Set tmpWS = Nothing

        End If
    Next i

    ws.Activate

    'important to reactivate the screen updating at the end
    Application.ScreenUpdating = True

End Sub
</code>```

Useful reference
On Error Statement

Body:
I am trying the below code, to copy a 'master' worksheet with renaming as per values in worksheet 'List', which is working only once.

If I try to run the macro again renaming does not happen.

runtime Error '1004':

  name is already taken . try a different one

The macro should work one loop and end. When rerun the macro should jump to the next value in the 'List'.

Private Sub CommandButton1_Click()
Dim i As Integer
Dim ws As Worksheet
Dim sh As Worksheet
Set ws = Sheets("Master")
Set sh = Sheets("List")
Application.ScreenUpdating = 0
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
    Application.CopyObjectsWithCells = False
    Sheets("Master").Copy After:=sh
    Application.CopyObjectsWithCells = True
    ActiveSheet.Name = sh.Range("A" & i).Value
    ActiveSheet.Range("F3").Value = sh.Range("A" & i).Value
Exit For
Next i
ws.Activate
End Sub

Body:
You were missing some info to tell the VBA code to loop if the current name (sh.Range("A" & i).value) was already taken by a worksheet.

Following is what I have come up with:

Private Sub CommandButton1_Click()
    Dim i As Integer
    Dim ws As Worksheet
    Dim sh As Worksheet

    Dim tmpWS As Worksheet 'will be used to test whether a worksheet already exists

    Set ws = Sheets("Master")
    Set sh = Sheets("List")

    'storing the last row I think is better as well as using explicit
    'definition of the range (sh.Range rather then Range alone)
    Dim lastRow As Integer
    lastRow = sh.Range("A" & Rows.Count).End(xlUp).Row

    Application.ScreenUpdating = False

    For i = 1 To lastRow

        'trying to set a worksheet variable with the new name from the list
        'if the result returns a set variable (variable not returning "Nothing")
        'it means the worksheet exists
        On Error Resume Next '--> will continue even if it encounters an error.  Don't overuse this
        Set tmpWS = ThisWorkbook.Worksheets(sh.Range("a" & i).Value2)
        On Error GoTo 0 '--> will set back default error handling.  From now on, the "Resume Next" is disabled.

        'this is true if worksheet named "sh.Range("A" & i).Value" does not exist
        If (tmpWS Is Nothing) Then

            Excel.Application.CopyObjectsWithCells = False
            Sheets("Master").Copy After:=sh
            ActiveSheet.Name = sh.Range("A" & i).Value
            ActiveSheet.Range("F3").Value = sh.Range("A" & i).Value
            Excel.Application.CopyObjectsWithCells = True
            Exit For

        Else

            'force tmpWS to be set to nothing prior making another run in the loop
            Set tmpWS = Nothing

        End If
    Next i

    ws.Activate

    'important to reactivate the screen updating at the end
    Application.ScreenUpdating = True

End Sub

Useful reference
On Error Statement


问:
Error while uploading a report
I have create a report using visual studio 2015 with SSDT Tools installed from the following link

https://msdn.microsoft.com/en-us/mt186501

The database is on SQL Server 2014.  The reports work on my machine however when I try to upload a report on customers machine(Which has SQL Server 2014 and not visual studio). I get the following error

"The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded. (rsInvalidReportDefinition)"

答: I right clicked on my report and then clicked publish report1.rdlc which worked for me.

Title: Error while uploading a report


问:
Excel VBA: PivotTable CubeField Fact Table Name?
I'm working with a large OLAP Cube, and I'm building very rudimentary search functionality to help me parse through the amount of data (~30 fact tables, 30 dimensions, plus calculated measures), but I've come across an interesting issue.  When I access a CubeField.Name property for a fact table member or a calculated measure, it comes through as [Measures].[FieldName] instead of pointing me to the correct Fact table / calculated measure folder.

Here's the code I'm using:

```<code>Sub X()

    Dim pvtTable As PivotTable
    Dim oCubeField As CubeField

    Set pvtTable = ActiveSheet.PivotTables(1)
    For Each oCubeField In pvtTable.CubeFields
        If InStr(LCase(oCubeField.Name), "spread") > 0 Then
            Debug.Print oCubeField.Parent & ": " & oCubeField.Name
        End If

    Next

End Sub
</code>```

Any ideas on how I can actually reach the fact table name?  Or the calculated measure's folder structure?  Thanks!

答:
Unfortunately, you can't do that, because a measure expression may link to a few fact tables.

But you can query and analyse cube metadata with OpenSchema() function.

Something like this:

```<code>Sub GetMeasuresList()
    Const adSchemaMeasures = 36

    Set ADOCon = ActiveCell.PivotTable.PivotCache.ADOConnection

    Set RecSet = ADOCon.OpenSchema(adSchemaMeasures)

    While Not RecSet.EOF
        Debug.Print RecSet!MEASURE_NAME & ": " & RecSet!EXPRESSION
        RecSet.MoveNext
    Wend

End Sub
</code>```

OLE DB for OLAP Schema Rowsets

How To Use the ADO OpenSchema Method in Visual Basic

Body:
I'm working with a large OLAP Cube, and I'm building very rudimentary search functionality to help me parse through the amount of data (~30 fact tables, 30 dimensions, plus calculated measures), but I've come across an interesting issue.  When I access a CubeField.Name property for a fact table member or a calculated measure, it comes through as [Measures].[FieldName] instead of pointing me to the correct Fact table / calculated measure folder.

Here's the code I'm using:

Sub X()

    Dim pvtTable As PivotTable
    Dim oCubeField As CubeField

    Set pvtTable = ActiveSheet.PivotTables(1)
    For Each oCubeField In pvtTable.CubeFields
        If InStr(LCase(oCubeField.Name), "spread") > 0 Then
            Debug.Print oCubeField.Parent & ": " & oCubeField.Name
        End If

    Next

End Sub

Any ideas on how I can actually reach the fact table name?  Or the calculated measure's folder structure?  Thanks!

Body:
Unfortunately, you can't do that, because a measure expression may link to a few fact tables.

But you can query and analyse cube metadata with OpenSchema() function.

Something like this:

Sub GetMeasuresList()
    Const adSchemaMeasures = 36

    Set ADOCon = ActiveCell.PivotTable.PivotCache.ADOConnection

    Set RecSet = ADOCon.OpenSchema(adSchemaMeasures)

    While Not RecSet.EOF
        Debug.Print RecSet!MEASURE_NAME & ": " & RecSet!EXPRESSION
        RecSet.MoveNext
    Wend

End Sub

OLE DB for OLAP Schema Rowsets

How To Use the ADO OpenSchema Method in Visual Basic