最終更新日: 2020-08-14 金 22:51
ホーム | 文書トップ | 目次

GnuTLS ビルド

Table of Contents

ソースの入手

configure

cd gnutls-3.6.14
./configure --prefix=/c/usr/gnutls --libdir=/c/msys64/mingw64/x86_64-w64-mingw32/lib
./configure --prefix=/c/usr/gnutls
make
make check
sudo make install
$ pacman -S libcrypt-devel

make

が、結局、下記のように "undefined reference" でリンクエラーになる。

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: system/.libs/keys-win.o: in function `cng_deinit':
D:\gnutls-3.6.14\lib/system/keys-win.c:685: undefined reference to `NCryptFreeObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: system/.libs/keys-win.o: in function `cng_sign':
D:\gnutls-3.6.14\lib/system/keys-win.c:602: undefined reference to `NCryptSignHash'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:617: undefined reference to `NCryptSignHash'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: system/.libs/keys-win.o: in function `cng_decrypt':
D:\gnutls-3.6.14\lib/system/keys-win.c:651: undefined reference to `NCryptDecrypt'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:665: undefined reference to `NCryptDecrypt'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: system/.libs/keys-win.o: in function `_gnutls_privkey_import_system_url':
D:\gnutls-3.6.14\lib/system/keys-win.c:892: undefined reference to `NCryptFreeObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:892: undefined reference to `NCryptFreeObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:861: undefined reference to `NCryptOpenStorageProvider'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: system/.libs/keys-win.o: in function `privkey_import_ncrypt':
D:\gnutls-3.6.14\lib/system/keys-win.c:710: undefined reference to `NCryptOpenKey'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:718: undefined reference to `NCryptGetProperty'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:759: undefined reference to `NCryptFreeObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: system/.libs/keys-win.o: in function `gnutls_system_key_delete':
D:\gnutls-3.6.14\lib/system/keys-win.c:1262: undefined reference to `NCryptDeleteKey'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\gnutls-3.6.14\lib/system/keys-win.c:1263: undefined reference to `NCryptFreeObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nettle/.libs/libcrypto.a(sysrng-bcrypt.o): in function `_rnd_get_system_entropy_win32':
D:\gnutls-3.6.14\lib\nettle/sysrng-bcrypt.c:58: undefined reference to `BCryptGenRandom'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nettle/.libs/libcrypto.a(sysrng-bcrypt.o): in function `_rnd_system_entropy_init':
D:\gnutls-3.6.14\lib\nettle/sysrng-bcrypt.c:74: undefined reference to `BCryptOpenAlgorithmProvider'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: nettle/.libs/libcrypto.a(sysrng-bcrypt.o): in function `_rnd_system_entropy_deinit':
D:\gnutls-3.6.14\lib\nettle/sysrng-bcrypt.c:87: undefined reference to `BCryptCloseAlgorithmProvider'
collect2.exe: error: ld returned 1 exit status

Win32API の bcrypt.h がインクルードされているはずで、スタティックライブラリへのリンクを通せばよいはず。

Windowsの bcrypt.lib は C:\Program Files (x86)\Windows Kits\ 以下や、C:\Program Files (x86)\Microsoft SDKs\ 以下にあるのだが、 これはそのままではリンクできないはず。

libbcrypt.a ならばリンクできるはずで、ファイルを探してみると、下記が存在する。

  • c:/msys64/mingw64/x86_64-w64-mingw32/lib/libbcrypt.a
  • c:/msys64/mingw32/i686-w64-mingw32/lib/libbcrypt.a
ホーム | 文書トップ | 目次
Created by Emacs 27.1 (Org mode 9.3)