<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<p class="details" style="font-style: italic; color: #666;">
<a href="https://gitlab.com/josuegomes">Josué Andrade Gomes</a> created an issue <a href="https://gitlab.com/gnutls/gnutls/-/issues/1117">#1117</a>:
</p>
<div></div>
<h2 dir="auto">
<a id="user-content-description-of-problem" class="anchor" href="#description-of-problem" aria-hidden="true"></a>Description of problem:</h2>
<p dir="auto">Undefined reference to __imp_gnutls_free error when linking with static build of GnuTLS.</p>
<h2 dir="auto">
<a id="user-content-version-of-gnutls-used" class="anchor" href="#version-of-gnutls-used" aria-hidden="true"></a>Version of gnutls used:</h2>
<p dir="auto">3.6.15</p>
<h2 dir="auto">
<a id="user-content-distributor-of-gnutls-eg-ubuntu-fedora-rhel" class="anchor" href="#distributor-of-gnutls-eg-ubuntu-fedora-rhel" aria-hidden="true"></a>Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)</h2>
<p dir="auto">gnutls.org</p>
<h2 dir="auto">
<a id="user-content-how-reproducible" class="anchor" href="#how-reproducible" aria-hidden="true"></a>How reproducible:</h2>
<p dir="auto">Windows 10</p>
<p dir="auto">Download MSYS2 from <a href="https://www.msys2.org/" rel="nofollow noreferrer noopener" target="_blank">https://www.msys2.org/</a></p>
<p dir="auto">Install MSYS2</p>
<p dir="auto">Upgrade and install development packages</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">$ pacman -Syu</span>
<span id="LC2" class="line" lang="plaintext">$ pacman -S autoconf automake libtool make mingw-w64-x86_64-toolchain git</span>
<span id="LC3" class="line" lang="plaintext"></span>
<span id="LC4" class="line" lang="plaintext">$ mkdir ~/prefix`</span>
<span id="LC5" class="line" lang="plaintext">$ export set PREFIX=/home/user/prefix</span>
<span id="LC6" class="line" lang="plaintext">$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig</span>
<span id="LC7" class="line" lang="plaintext"></span>
<span id="LC8" class="line" lang="plaintext">$ cd ~</span>
<span id="LC9" class="line" lang="plaintext">$ curl -O https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz</span>
<span id="LC10" class="line" lang="plaintext">$ tar xf gmp-6.2.0.tar.xz</span>
<span id="LC11" class="line" lang="plaintext">$ cd gmp-6.2.0</span>
<span id="LC12" class="line" lang="plaintext">$ ./configure --build=x86_64-w64-mingw32 --prefix=$PREFIX --enable-static --disable-shared --enable-fat</span>
<span id="LC13" class="line" lang="plaintext">$ make install</span>
<span id="LC14" class="line" lang="plaintext"></span>
<span id="LC15" class="line" lang="plaintext">$ cd ~</span>
<span id="LC16" class="line" lang="plaintext">$ curl -O https://ftp.gnu.org/gnu/nettle/nettle-3.5.1.tar.gz</span>
<span id="LC17" class="line" lang="plaintext">$ tar xf nettle-3.5.1.tar.gz</span>
<span id="LC18" class="line" lang="plaintext">$ cd nettle-3.5.1</span>
<span id="LC19" class="line" lang="plaintext">$ ./configure --build=x86_64-w64-mingw32 --prefix=$PREFIX --enable-static --disable-shared --enable-fat</span>
<span id="LC20" class="line" lang="plaintext">$ make install</span>
<span id="LC21" class="line" lang="plaintext"></span>
<span id="LC22" class="line" lang="plaintext">$ cd ~</span>
<span id="LC23" class="line" lang="plaintext">$ curl -O ftp://ftp.gnutls.org/gcrypt/gnutls/v3.6/gnutls-3.6.15.tar.xz</span>
<span id="LC24" class="line" lang="plaintext">$ tar xf gnutls-3.6.15.tar.xz</span>
<span id="LC25" class="line" lang="plaintext">$ cd gnutls-3.6.15</span>
<span id="LC26" class="line" lang="plaintext">$ ./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</span>
<span id="LC27" class="line" lang="plaintext">$ make && make install</span>
<span id="LC28" class="line" lang="plaintext"></span>
<span id="LC29" class="line" lang="plaintext">$ cd ~</span>
<span id="LC30" class="line" lang="plaintext">$ g++ -o bug -DWIN32 -D_WIN32 -I $PREFIX/include bug.cpp -L$PREFIX/lib -lgnutls -lhogweed -lnettle -lgmp -ladvapi32 -lws2_32 -lcrypt32 -lncrypt</span>
<span id="LC31" class="line" lang="plaintext"></span></code></pre>
<p dir="auto">bug.cpp</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">#include <gnutls/gnutls.h></span>
<span id="LC2" class="line" lang="plaintext"></span>
<span id="LC3" class="line" lang="plaintext">int main()</span>
<span id="LC4" class="line" lang="plaintext">{</span>
<span id="LC5" class="line" lang="plaintext">       gnutls_init(0, 0);</span>
<span id="LC6" class="line" lang="plaintext">       gnutls_free(0);</span>
<span id="LC7" class="line" lang="plaintext">}</span>
<span id="LC8" class="line" lang="plaintext"></span></code></pre>
<h2 dir="auto">
<a id="user-content-actual-results" class="anchor" href="#actual-results" aria-hidden="true"></a>Actual results:</h2>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"></span>
<span id="LC2" class="line" lang="plaintext">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'</span>
<span id="LC3" class="line" lang="plaintext">collect2.exe: error: ld returned 1 exit status</span>
<span id="LC4" class="line" lang="plaintext"></span></code></pre>
<h2 dir="auto">
<a id="user-content-expected-results" class="anchor" href="#expected-results" aria-hidden="true"></a>Expected results:</h2>
<p dir="auto">No link error</p>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1117">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/0036dd4dd30645c6a701697a66b8434a/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1117"}}</script>


</p>
</div>
</body>
</html>