randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.55k stars 561 forks source link

Can not cross compile a Windows DLL on Linux using Mingw #2788

Closed snowyu closed 3 years ago

snowyu commented 3 years ago

It reports WARNING: Shared libs not supported on mingw, disabling shared lib support

>./configure.py --os=mingw --cpu=x86_32 --cc-bin=i686-w64-mingw32-g++-posix --ar-command=i686-w64-mingw32-ar --enable-shared-library
   INFO: ./configure.py invoked with options "--os=mingw --cpu=x86_32 --cc-bin=i686-w64-mingw32-g++-posix --ar-command=i686-w64-mingw32-ar --enable-shared-library"
   INFO: Configuring to build Botan 3.0.0-alpha0 (revision git:37fe3a2f3b806cbb2d4db4c2bb19eb7f2a673bef)
   INFO: Running under 2.7.18 (default, Mar  8 2021, 13:02:45) [GCC 9.3.0]
   INFO: Autodetected platform information: OS="Linux" machine="x86_64" proc="x86_64"
   INFO: Using /etc/ssl/certs/ca-certificates.crt as system certificate store
WARNING: Shared libs not supported on mingw, disabling shared lib support
   INFO: Auto-detected compiler version 9.3
   INFO: Auto-detected compiler arch x86_32
   INFO: Target is gcc:9.3-mingw-x86_32
   INFO: Assuming target x86_32 is little endian
   INFO: Skipping (dependency failure): asio certstor_sqlite3 sessions_sqlite3
   INFO: Skipping (incompatible CPU): aes_armv8 aes_power8 sha1_armv8 sha2_32_armv8 sha2_64_bmi2 sha3_bmi2 shacal2_armv8 sm4_armv8
   INFO: Skipping (incompatible OS): certstor_system_macos commoncrypto fd_unix getentropy
   INFO: Skipping (no enabled compression schemes): compression
   INFO: Skipping (requires external dependency): boost bzip2 lzma openssl sqlite3 tpm zlib
   INFO: Loading modules: adler32 aead aes aes_ni aes_vperm argon2 argon2fmt aria asn1 auto_rng base base32 base58 base64 bcrypt bcrypt_pbkdf bigint blake2 blake2mac block blowfish camellia cascade cast128 cbc ccm cecpq1 certstor_flatfile certstor_sql certstor_system certstor_system_windows cfb chacha chacha20poly1305 chacha_avx2 chacha_rng chacha_simd32 checksum cmac comb4p cpuid crc24 crc32 cryptobox ctr curve25519 des dh dl_algo dl_group dlies dsa dyn_load eax ec_group ec_h2c ecc_key ecdh ecdsa ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa1 emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy ffi filters fpe_fe1 gcm ghash ghash_cpu ghash_vperm gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg hotp http_util idea idea_sse2 iso9796 kdf kdf1 kdf1_iso18033 kdf2 keccak keypair lion locking_allocator mac mce md4 md5 mdx_hash mem_pool mgf1 mode_pad modes mp newhope nist_keywrap noekeon noekeon_simd numbertheory ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf2 pem pgp_s2k pk_pad pkcs11 poly1305 poly_dbl prf_tls prf_x942 processor_rng psk_db pubkey rc4 rdseed rfc3394 rfc6979 rmd160 rng roughtime rsa salsa20 scrypt seed serpent serpent_avx2 serpent_simd sessions_sql sha1 sha1_sse2 sha1_x86 sha2_32 sha2_32_bmi2 sha2_32_x86 sha2_64 sha3 shacal2 shacal2_avx2 shacal2_simd shacal2_x86 shake shake_cipher simd simd_avx2 siphash siv skein sm2 sm3 sm4 socket sodium sp800_108 sp800_56a sp800_56c srp6 stateful_rng stream streebog system_rng thread_utils threefish_512 threefish_512_avx2 tls tls_cbc tss twofish utils uuid whirlpool win32_stats x509 x919_mac xmss xts
   INFO: Using symlink to link files into build dir (use --link-method to change)
   INFO: Botan 3.0.0-alpha0 (revision git:37fe3a2f3b806cbb2d4db4c2bb19eb7f2a673bef) (unreleased undated) build setup is complete

>lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:printing-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal
randombit commented 3 years ago

I had thought this didn't work for some reason or in some circumstances. But feel free to give this a try, if it works I can add to master

diff --git a/src/build-data/os/mingw.txt b/src/build-data/os/mingw.txt
index b2cc2f0b8..300bed81e 100644
--- a/src/build-data/os/mingw.txt
+++ b/src/build-data/os/mingw.txt
@@ -8,6 +8,9 @@ header_dir include
 lib_dir lib
 doc_dir share/doc

+soname_pattern_base "{libname}.dll"
+shared_lib_symlinks no
+
 # see https://sourceforge.net/p/mingw-w64/bugs/755/
 use_stack_protector no
snowyu commented 3 years ago

confirmed, It works.