[gnutls-devel] GnuTLS | Undefined reference to __imp_gnutls_free error with static build on MinGW (#1117)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Thu Nov 12 11:42:32 CET 2020
Josué Andrade Gomes created an issue: https://gitlab.com/gnutls/gnutls/-/issues/1117
## Description of problem:
Undefined reference to __imp_gnutls_free error when linking with static build of GnuTLS.
## Version of gnutls used:
3.6.15
## Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)
gnutls.org
## How reproducible:
Windows 10
Download MSYS2 from https://www.msys2.org/
Install MSYS2
Upgrade and install development packages
```
$ pacman -Syu
$ pacman -S autoconf automake libtool make mingw-w64-x86_64-toolchain git
$ mkdir ~/prefix`
$ export set PREFIX=/home/user/prefix
$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
$ cd ~
$ curl -O https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz
$ tar xf gmp-6.2.0.tar.xz
$ cd gmp-6.2.0
$ ./configure --build=x86_64-w64-mingw32 --prefix=$PREFIX --enable-static --disable-shared --enable-fat
$ make install
$ cd ~
$ curl -O https://ftp.gnu.org/gnu/nettle/nettle-3.5.1.tar.gz
$ tar xf nettle-3.5.1.tar.gz
$ cd nettle-3.5.1
$ ./configure --build=x86_64-w64-mingw32 --prefix=$PREFIX --enable-static --disable-shared --enable-fat
$ make install
$ cd ~
$ curl -O ftp://ftp.gnutls.org/gcrypt/gnutls/v3.6/gnutls-3.6.15.tar.xz
$ tar xf gnutls-3.6.15.tar.xz
$ cd gnutls-3.6.15
$ ./configure --prefix=$PREFIX --enable-static --disable-shared --build=x86_64-w64-mingw32 --with-included-libtasn1 --disable-doc --disable-guile --without-p11-kit --enable-local-libopts --disable-nls --with-included-unistring
$ make && make install
$ cd ~
$ g++ -o bug -DWIN32 -D_WIN32 -I $PREFIX/include bug.cpp -L$PREFIX/lib -lgnutls -lhogweed -lnettle -lgmp -ladvapi32 -lws2_32 -lcrypt32 -lncrypt
```
bug.cpp
```
#include <gnutls/gnutls.h>
int main()
{
gnutls_init(0, 0);
gnutls_free(0);
}
```
## Actual results:
```
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:\msys64\tmp\ccKcC8Qw.o:bug.cpp:(.text+0x1f): undefined reference to `__imp_gnutls_free'
collect2.exe: error: ld returned 1 exit status
```
## Expected results:
No link error
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/issues/1117
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20201112/12f8744a/attachment-0001.html>
More information about the Gnutls-devel
mailing list