[vbox-dev] Problem building VBox for Windows with gSOAP 2.8.45

Konstantin Vlasov flint at flint-inc.ru
Fri May 12 16:39:48 GMT 2017


Hi,

OK, as it usually happens, just as I sent this plea for help I figured out how 
to solve it myself. :-)

After examinig the verbose linker log I discovered that with 2.8.44 the OpenSSL
libraries are searched for symbols but nothing is found (everything is taken
from VBoxRT.lib), and with 2.8.45 the linker finds there the new functions. I
take it that in the first case the linker simply skips the library and does not
load it, therefore no conflicts.

So I edited the VBoxRT-openssl-1.1plus.def file and added X509_STORE_set_flags
to the export list, rebuilt vboxwebsrv.exe - and voila, no errors with 2.8.45!

I suggest to oficially include this to the VB sources:

diff --git a/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def b/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def
index 92e186e..d8b5837 100644
--- a/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def
+++ b/src/VBox/Runtime/r3/win/VBoxRT-openssl-1.1plus.def
@@ -204,6 +204,7 @@
     X509_VERIFY_PARAM_free
     X509_VERIFY_PARAM_new
     X509_VERIFY_PARAM_set_flags
+    X509_STORE_set_flags
     X509V3_conf_free

     ; tstRTBigNum.cpp


MIT license.


>   Hi,

> I met a strange problem building VirtualBox for Windows. Details are given 
> below, but what generally happens is:
> There is some function in OpenSSL that is used by gSOAP; let's call it 
> function A(). The definition is simple:

> int A() {
>     return B();
> }

> But if I edit gSOAP and replace the call to A() with B(), suddently 
> vboxwebsrv.exe stops building and returns multiple linker errors about symbol 
> conflicts between OpenSSL and VBoxRT.lib, and several unresolved externals.

> How could that be?

> =================================================
> Now, all the gore details.


> I'm trying to build Windows version of VirtualBox 5.1.22 with latest libraries, 
> particularly:
> * curl 7.54.0
> * OpenSSL 1.1.0e
> * gSOAP 2.8.45

> With gSOAP 2.8.44 it compiled without problems, but with 2.8.45 linker errors 
> occur when trying to link vboxwebsrv.exe. I compared gSOAP source code for those
> versions and narrowed it down to specific change that causes the problem:

> gsoap_2.8.44.zip\gsoap-2.8\gsoap\stdsoap2.cpp:3575 soap_ssl_crl()
>     X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
>     X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
>     X509_STORE_set1_param(store, param);
>     X509_VERIFY_PARAM_free(param);

> gsoap_2.8.45.zip\gsoap-2.8\gsoap\stdsoap2.cpp:3578 soap_ssl_crl()
>     X509_STORE_set_flags(store, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);

> (Four lines were replaced with one.)

> Actually, there are several files that are identical to this stdsoap2.cpp:
> * stdsoap2.c
> * samples\calc_vs2005\calc_vs2005\stdsoap2.cpp
> * VisualStudio2005\wsdl2h\wsdl2h\stdsoap2.cpp
> I didn't investigate which ones are used, so when I'm talking about just 
> stdsoap2.cpp I mean all of them: copying, editing, etc., so that they always 
> remain identical to each other.


> Now, if I use 2.8.45 and try to build vboxwebsrv.exe I get the following output:
>     
> libcrypto.lib(x509_lu.obj) : error LNK2005: X509_STORE_add_lookup already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(stack.obj) : error LNK2005: OPENSSL_sk_num already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(stack.obj) : error LNK2005: OPENSSL_sk_value already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(stack.obj) : error LNK2005: OPENSSL_sk_pop_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(mem.obj) : error LNK2005: CRYPTO_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509_cmp.obj) : error LNK2005: X509_get_subject_name already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(err.obj) : error LNK2005: ERR_clear_error already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(err.obj) : error LNK2005: ERR_error_string_n already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(err.obj) : error LNK2005: ERR_error_string already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(err.obj) : error LNK2005: ERR_get_error already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(err.obj) : error LNK2005: ERR_peek_error already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509_vfy.obj) : error LNK2005: X509_STORE_CTX_get_error already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509_vfy.obj) : error LNK2005: X509_STORE_CTX_set_error already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x_x509.obj) : error LNK2005: X509_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(v3_utl.obj) : error LNK2005: X509V3_conf_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509_ext.obj) : error LNK2005: X509_get_ext_d2i already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(asn1_lib.obj) : error LNK2005: ASN1_STRING_data already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(v3_genn.obj) : error LNK2005: GENERAL_NAME_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(init.obj) : error LNK2005: OPENSSL_init_crypto already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509name.obj) : error LNK2005: X509_NAME_get_entry already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509name.obj) : error LNK2005: X509_NAME_ENTRY_get_data already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(x509name.obj) : error LNK2005: X509_NAME_get_index_by_NID
> already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(bio_lib.obj) : error LNK2005: BIO_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(bio_lib.obj) : error LNK2005: BIO_read already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(bio_lib.obj) : error LNK2005: BIO_write already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(a_strex.obj) : error LNK2005: ASN1_STRING_to_UTF8 already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(dh_lib.obj) : error LNK2005: DH_free already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(v3_alt.obj) : error LNK2005: i2v_GENERAL_NAMES already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(rand_lib.obj) : error LNK2005: RAND_seed already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(rand_lib.obj) : error LNK2005: RAND_pseudo_bytes already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(rand_lib.obj) : error LNK2005: RAND_status already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(bss_file.obj) : error LNK2005: BIO_new_file already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(pem_pkey.obj) : error LNK2005: PEM_read_bio_DHparams already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(bss_sock.obj) : error LNK2005: BIO_new_socket already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(dh_check.obj) : error LNK2005: DH_check already defined in VBoxRT.lib(VBoxRT.dll)
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertFreeCertificateContext referenced in function capi_free_key
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertGetCertificateContextProperty referenced in function capi_get_prov_info
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertOpenStore referenced in function capi_open_store
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertFindCertificateInStore referenced in function capi_find_cert
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertEnumCertificatesInStore referenced in function capi_find_cert
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertCloseStore referenced in function capi_find_key
> libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol
> __imp_CertDuplicateCertificateContext referenced in function capi_load_ssl_client_cert
> C:/Devel/VirtualBox-src/out/win.amd64/release/obj/vboxwebsrv/vboxwebsrv.exe :
> fatal error LNK1120: 7 unresolved externals

> If I edit stdsoap2.cpp and replace that one X509_STORE_set_flags() call with 
> those 4 lines from 2.8.44, everything is compiled and linked without any errors 
> or warnings.


> I then tried to substitute OpenSSL functions to find out how they might cause 
> such linkage problem. I ended up with even stranger results.

> 1. First, I take the "patched" 2.8.45 version which compiles correctly.

> 2. Then I add the x509_store_st structure definition into stdsoap2.cpp by 
> copying it from openssl-1.1.0e\crypto\x509\x509_lcl.h (I will need it later); 
> check that it still compiles without any problems.

> 3. In the openssl-1.1.0e\crypto\x509\x509_lu.c I find the function definition:

> int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param)
> {
>     return X509_VERIFY_PARAM_set1(ctx->param, param);
> }

> and replace X509_STORE_set1_param() call in the stdsoap2.cpp with the its 
> contents:

>     X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
>     X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
>     X509_VERIFY_PARAM_set1(store->param, param);     /* <----   HERE */
>     X509_VERIFY_PARAM_free(param);

> 4. Now I try to compile the code - and obtain the same linker errors posted 
> above! (Plus 3 more duplicates: X509_VERIFY_PARAM_free, X509_VERIFY_PARAM_new, 
> X509_VERIFY_PARAM_set_flags).

> What is happening here?


-- 
Bye.                                    With best regards,
                                        Konstantin Vlasov.




More information about the vbox-dev mailing list