Page 1 of 1

building the noob livebook version of Stockfish for Windows

Posted: Fri Nov 22, 2019 3:48 am
by Dann Corbit
I was trying to help someone else, but I can't seem to get it right either.
It seems that the curl library has a pile of dependencies and I cannot figure out the right way to add all the necessary libraries.
https://github.com/noobpwnftw/Stockfish/tree/livebook

My experimental LDFLAGS looks like this:
LDFLAGS += -lnghttp2 -lbrotlicommon-static -lz -lidn2 -lwldap32 -lcurl -lssl -lcrypto -lws2_32 $(EXTRALDFLAGS)

All the libraries are found, but some must not be correct or the order is wrong.

I get the following undefined references:

Code: Select all

undefined reference to `BrotliDecoderCreateInstance'
undefined reference to `BrotliDecoderDecompressStream'
undefined reference to `BrotliDecoderDestroyInstance'
undefined reference to `BrotliDecoderGetErrorCode'
undefined reference to `BrotliDecoderVersion'
undefined reference to `__imp_CertAddCertificateContextToStore'
undefined reference to `__imp_CertCloseStore'
undefined reference to `__imp_CertCreateCertificateChainEngine'
undefined reference to `__imp_CertEnumCertificatesInStore'
undefined reference to `__imp_CertFindCertificateInStore'
undefined reference to `__imp_CertFreeCertificateChain'
undefined reference to `__imp_CertFreeCertificateChainEngine'
undefined reference to `__imp_CertFreeCertificateContext'
undefined reference to `__imp_CertGetCertificateChain'
undefined reference to `__imp_CertGetNameStringA'
undefined reference to `__imp_CertOpenStore'
undefined reference to `__imp_CryptQueryObject'
undefined reference to `__imp_CryptStringToBinaryA'
undefined reference to `__imp_ber_free'
undefined reference to `__imp_ldap_bind_s'
undefined reference to `__imp_ldap_err2string'
undefined reference to `__imp_ldap_first_attribute'
undefined reference to `__imp_ldap_first_entry'
undefined reference to `__imp_ldap_get_dn'
undefined reference to `__imp_ldap_get_values_len'
undefined reference to `__imp_ldap_init'
undefined reference to `__imp_ldap_memfree'
undefined reference to `__imp_ldap_msgfree'
undefined reference to `__imp_ldap_next_attribute'
undefined reference to `__imp_ldap_next_entry'
undefined reference to `__imp_ldap_search_s'
undefined reference to `__imp_ldap_set_option'
undefined reference to `__imp_ldap_simple_bind_s'
undefined reference to `__imp_ldap_sslinit'
undefined reference to `__imp_ldap_unbind_s'
undefined reference to `__imp_ldap_value_free_len'
undefined reference to `__imp_nghttp2_http2_strerror'
undefined reference to `__imp_nghttp2_is_fatal'
undefined reference to `__imp_nghttp2_pack_settings_payload'
undefined reference to `__imp_nghttp2_priority_spec_init'
undefined reference to `__imp_nghttp2_session_callbacks_del'
undefined reference to `__imp_nghttp2_session_callbacks_new'
undefined reference to `__imp_nghttp2_session_callbacks_set_error_callback'
undefined reference to `__imp_nghttp2_session_callbacks_set_on_begin_headers_callback'
undefined reference to `__imp_nghttp2_session_callbacks_set_on_data_chunk_recv_callback'
undefined reference to `__imp_nghttp2_session_callbacks_set_on_frame_recv_callback'
undefined reference to `__imp_nghttp2_session_callbacks_set_on_header_callback'
undefined reference to `__imp_nghttp2_session_callbacks_set_on_stream_close_callback'
undefined reference to `__imp_nghttp2_session_callbacks_set_send_callback'
undefined reference to `__imp_nghttp2_session_client_new'
undefined reference to `__imp_nghttp2_session_del'
undefined reference to `__imp_nghttp2_session_get_remote_settings'
undefined reference to `__imp_nghttp2_session_get_stream_user_data'
undefined reference to `__imp_nghttp2_session_mem_recv'
undefined reference to `__imp_nghttp2_session_resume_data'
undefined reference to `__imp_nghttp2_session_send'
undefined reference to `__imp_nghttp2_session_set_local_window_size'
undefined reference to `__imp_nghttp2_session_set_stream_user_data'
undefined reference to `__imp_nghttp2_session_upgrade'
undefined reference to `__imp_nghttp2_session_want_read'
undefined reference to `__imp_nghttp2_session_want_write'
undefined reference to `__imp_nghttp2_strerror'
undefined reference to `__imp_nghttp2_submit_ping'
undefined reference to `__imp_nghttp2_submit_priority'
undefined reference to `__imp_nghttp2_submit_request'
undefined reference to `__imp_nghttp2_submit_rst_stream'
undefined reference to `__imp_nghttp2_submit_settings'
undefined reference to `__imp_nghttp2_version'
undefined reference to `idn2_check_version'
undefined reference to `idn2_free'
undefined reference to `idn2_lookup_ul'
undefined reference to `idn2_strerror'
undefined reference to `inflate'
undefined reference to `inflateEnd'
undefined reference to `inflateInit2_'
undefined reference to `inflateInit_'
undefined reference to `psl_builtin'
undefined reference to `psl_free'
undefined reference to `psl_get_version'
undefined reference to `psl_is_cookie_domain_acceptable'
undefined reference to `psl_latest'
undefined reference to `zlibVersion'

Re: building the noob livebook version of Stockfish for Windows

Posted: Fri Nov 22, 2019 5:37 pm
by mig2004
Hi Dan,

I got this error from your source: search.cpp: 42:10: fatal error: curl/curl.h: No such file or directory 42| #include <curl/curl.h>

Re: building the noob livebook version of Stockfish for Windows

Posted: Fri Nov 22, 2019 7:04 pm
by mar
Dann Corbit wrote: Fri Nov 22, 2019 3:48 am My experimental LDFLAGS looks like this:
LDFLAGS += -lnghttp2 -lbrotlicommon-static -lz -lidn2 -lwldap32 -lcurl -lssl -lcrypto -lws2_32 $(EXTRALDFLAGS)

All the libraries are found, but some must not be correct or the order is wrong.
Yes, this seems to be my favorite "feature" of the insanely stupid gcc linker.
You have to sort the linked libraries in order of dependencies, i.e.
say if A depends on B depends on C then you have to link A first, then B, then C, otherwise you get linker errors
as the linker "optimizes away".

Re: building the noob livebook version of Stockfish for Windows

Posted: Fri Nov 22, 2019 7:13 pm
by Dann Corbit
I don't suppose that there is some tool to analyze the libraries in order to determine the right order?
I don't want to try 9! possible orderings to find the right one.

Re: building the noob livebook version of Stockfish for Windows

Posted: Fri Nov 22, 2019 7:15 pm
by Dann Corbit
mig2004 wrote: Fri Nov 22, 2019 5:37 pm Hi Dan,

I got this error from your source: search.cpp: 42:10: fatal error: curl/curl.h: No such file or directory 42| #include <curl/curl.h>
You need to install curl first with pacman (assuming you are using msys2).

It is not my source, it belongs to noob (Bojun Guo).

The idea of it ( I think ) is to correct directly to his oracle and use it as a book.

Re: building the noob livebook version of Stockfish for Windows

Posted: Fri Nov 22, 2019 7:54 pm
by mar
Dann Corbit wrote: Fri Nov 22, 2019 7:13 pm I don't suppose that there is some tool to analyze the libraries in order to determine the right order?
I don't want to try 9! possible orderings to find the right one.
The linker errors may guide you, if you get linker error for library x, push it down the link chain :)