curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

MinGW Cross-Compiling results in error "ld: cannot find -link"

From: Michael Fabian Dirks via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 28 Oct 2019 00:25:57 +0100

Hello,

I'm trying to build libcurl for Windows using Ubuntu's 'mingw-w64'
package. Since I'm building from the git repository, and the CMake
script has a message stating that it is poorly maintained, I wanted to
build it through configure with make. As there is no configure file in
the git repo, I made one using:

> git reset --hard
> git clean -fdx
> autoreconf -i
And then configured it with:
> ./configure --prefix=$_SYSROOT --host=x86_64-w64-mingw32 --with-gnu-ld
> --with-pic --disable-debug --enable-optimize --disable-curldebug
> --disable-dependency-tracking --enable-shared --enable-static
> --enable-http --enable-ftp --enable-file --enable-proxy --enable-ipv6
> --enable-threaded-resolver --enable-pthreads --enable-sspi
> --enable-crypto-auth --enable-tls-srp --enable-http-auth
> --enable-cookies --enable-doh --enable-mime --enable-progress-meter
> --enable-dnsshuffle --disable-ldap --disable-ldaps --disable-rtsp
> --disable-dict --disable-telnet --disable-tftp --disable-pop3
> --disable-imap --disable-smb --disable-smtp --disable-gopher
> --disable-manual --disable-versioned-symbols --disable-unix-sockets
> --disable-dateparse --disable-netrc --disable-alt-svc --without-ssl
> --with-sysroot=$_SYSROOT --withzlib=$_SYSROOT --with-mbedtls=$_SYSROOT
It configures fine, but for an unknown reason a sed command is added to
the linker command which replaces all '-lLIBRARY' with '-link LIBRARY',
and it seems impossible to remove. Removing the
'--host=x86_64-w64-mingw32' makes it link, but then fails that it
couldn't find libcurl.so (as the cross compile toolchain produces .dll
files). The command that breaks is:

> echo "  CCLD    " libcurl.la;/bin/bash ../libtool --silent --tag=CC  
> --mode=link x86_64-w64-mingw32-gcc-win32   -static-libgcc
> -static-libstdc++ -O2 -pthread   -version-info 10:0:6 -no-undefined
> -static-libgcc -static-libstdc++
> -L/mnt/d/Projects/Xaymar/obs-deps/build/win64/lib
> -L/mnt/d/Projects/Xaymar/obs-deps/build/win64/lib -lmbedtls -lmbedx509
> -lmbedcrypto -lz -lws2_32 -static-libgcc -static-libstdc++
> -L/mnt/d/Projects/Xaymar/obs-deps/build/win64/lib
> -L/mnt/d/Projects/Xaymar/obs-deps/build/win64/lib -o libcurl.la -rpath
> /mnt/d/Projects/Xaymar/obs-deps/build/win64/lib libcurl_la-file.lo
> libcurl_la-timeval.lo libcurl_la-base64.lo libcurl_la-hostip.lo
> libcurl_la-progress.lo libcurl_la-formdata.lo libcurl_la-cookie.lo
> libcurl_la-http.lo libcurl_la-sendf.lo libcurl_la-ftp.lo
> libcurl_la-url.lo libcurl_la-dict.lo libcurl_la-if2ip.lo
> libcurl_la-speedcheck.lo libcurl_la-ldap.lo libcurl_la-version.lo
> libcurl_la-getenv.lo libcurl_la-escape.lo libcurl_la-mprintf.lo
> libcurl_la-telnet.lo libcurl_la-netrc.lo libcurl_la-getinfo.lo
> libcurl_la-transfer.lo libcurl_la-strcase.lo libcurl_la-easy.lo
> libcurl_la-security.lo libcurl_la-curl_fnmatch.lo
> libcurl_la-fileinfo.lo libcurl_la-ftplistparser.lo
> libcurl_la-wildcard.lo libcurl_la-krb5.lo libcurl_la-memdebug.lo
> libcurl_la-http_chunks.lo libcurl_la-strtok.lo libcurl_la-connect.lo
> libcurl_la-llist.lo libcurl_la-hash.lo libcurl_la-multi.lo
> libcurl_la-content_encoding.lo libcurl_la-share.lo
> libcurl_la-http_digest.lo libcurl_la-md4.lo libcurl_la-md5.lo
> libcurl_la-http_negotiate.lo libcurl_la-inet_pton.lo
> libcurl_la-strtoofft.lo libcurl_la-strerror.lo libcurl_la-amigaos.lo
> libcurl_la-hostasyn.lo libcurl_la-hostip4.lo libcurl_la-hostip6.lo
> libcurl_la-hostsyn.lo libcurl_la-inet_ntop.lo libcurl_la-parsedate.lo
> libcurl_la-select.lo libcurl_la-tftp.lo libcurl_la-splay.lo
> libcurl_la-strdup.lo libcurl_la-socks.lo libcurl_la-curl_addrinfo.lo
> libcurl_la-socks_gssapi.lo libcurl_la-socks_sspi.lo
> libcurl_la-curl_sspi.lo libcurl_la-slist.lo libcurl_la-nonblock.lo
> libcurl_la-curl_memrchr.lo libcurl_la-imap.lo libcurl_la-pop3.lo
> libcurl_la-smtp.lo libcurl_la-pingpong.lo libcurl_la-rtsp.lo
> libcurl_la-curl_threads.lo libcurl_la-warnless.lo libcurl_la-hmac.lo
> libcurl_la-curl_rtmp.lo libcurl_la-openldap.lo
> libcurl_la-curl_gethostname.lo libcurl_la-gopher.lo
> libcurl_la-idn_win32.lo libcurl_la-http_proxy.lo
> libcurl_la-non-ascii.lo libcurl_la-asyn-ares.lo
> libcurl_la-asyn-thread.lo libcurl_la-curl_gssapi.lo
> libcurl_la-http_ntlm.lo libcurl_la-curl_ntlm_wb.lo
> libcurl_la-curl_ntlm_core.lo libcurl_la-curl_sasl.lo
> libcurl_la-rand.lo libcurl_la-curl_multibyte.lo
> libcurl_la-hostcheck.lo libcurl_la-conncache.lo libcurl_la-dotdot.lo
> libcurl_la-x509asn1.lo libcurl_la-http2.lo libcurl_la-smb.lo
> libcurl_la-curl_endian.lo libcurl_la-curl_des.lo
> libcurl_la-system_win32.lo libcurl_la-mime.lo libcurl_la-sha256.lo
> libcurl_la-setopt.lo libcurl_la-curl_path.lo libcurl_la-curl_ctype.lo
> libcurl_la-curl_range.lo libcurl_la-psl.lo libcurl_la-doh.lo
> libcurl_la-urlapi.lo libcurl_la-curl_get_line.lo libcurl_la-altsvc.lo
> libcurl_la-socketpair.lo vauth/libcurl_la-vauth.lo
> vauth/libcurl_la-cleartext.lo vauth/libcurl_la-cram.lo
> vauth/libcurl_la-digest.lo vauth/libcurl_la-digest_sspi.lo
> vauth/libcurl_la-krb5_gssapi.lo vauth/libcurl_la-krb5_sspi.lo
> vauth/libcurl_la-ntlm.lo vauth/libcurl_la-ntlm_sspi.lo
> vauth/libcurl_la-oauth2.lo vauth/libcurl_la-spnego_gssapi.lo
> vauth/libcurl_la-spnego_sspi.lo vtls/libcurl_la-openssl.lo
> vtls/libcurl_la-gtls.lo vtls/libcurl_la-vtls.lo vtls/libcurl_la-nss.lo
> vtls/libcurl_la-polarssl.lo vtls/libcurl_la-polarssl_threadlock.lo
> vtls/libcurl_la-wolfssl.lo vtls/libcurl_la-schannel.lo
> vtls/libcurl_la-schannel_verify.lo vtls/libcurl_la-sectransp.lo
> vtls/libcurl_la-gskit.lo vtls/libcurl_la-mbedtls.lo
> vtls/libcurl_la-mesalink.lo vquic/libcurl_la-ngtcp2.lo
> vquic/libcurl_la-quiche.lo vssh/libcurl_la-libssh2.lo
> vssh/libcurl_la-libssh.lo
Which generates the actual command:

> libtool: link: x86_64-w64-mingw32-gcc-win32 -o .libs/libcurl.dll.a
> .libs/libcurl_la-file.o .libs/libcurl_la-timeval.o
> .libs/libcurl_la-base64.o .libs/libcurl_la-hostip.o
> .libs/libcurl_la-progress.o .libs/libcurl_la-formdata.o
> .libs/libcurl_la-cookie.o .libs/libcurl_la-http.o
> .libs/libcurl_la-sendf.o .libs/libcurl_la-ftp.o .libs/libcurl_la-url.o
> .libs/libcurl_la-dict.o .libs/libcurl_la-if2ip.o
> .libs/libcurl_la-speedcheck.o .libs/libcurl_la-ldap.o
> .libs/libcurl_la-version.o .libs/libcurl_la-getenv.o
> .libs/libcurl_la-escape.o .libs/libcurl_la-mprintf.o
> .libs/libcurl_la-telnet.o .libs/libcurl_la-netrc.o
> .libs/libcurl_la-getinfo.o .libs/libcurl_la-transfer.o
> .libs/libcurl_la-strcase.o .libs/libcurl_la-easy.o
> .libs/libcurl_la-security.o .libs/libcurl_la-curl_fnmatch.o
> .libs/libcurl_la-fileinfo.o .libs/libcurl_la-ftplistparser.o
> .libs/libcurl_la-wildcard.o .libs/libcurl_la-krb5.o
> .libs/libcurl_la-memdebug.o .libs/libcurl_la-http_chunks.o
> .libs/libcurl_la-strtok.o .libs/libcurl_la-connect.o
> .libs/libcurl_la-llist.o .libs/libcurl_la-hash.o
> .libs/libcurl_la-multi.o .libs/libcurl_la-content_encoding.o
> .libs/libcurl_la-share.o .libs/libcurl_la-http_digest.o
> .libs/libcurl_la-md4.o .libs/libcurl_la-md5.o
> .libs/libcurl_la-http_negotiate.o .libs/libcurl_la-inet_pton.o
> .libs/libcurl_la-strtoofft.o .libs/libcurl_la-strerror.o
> .libs/libcurl_la-amigaos.o .libs/libcurl_la-hostasyn.o
> .libs/libcurl_la-hostip4.o .libs/libcurl_la-hostip6.o
> .libs/libcurl_la-hostsyn.o .libs/libcurl_la-inet_ntop.o
> .libs/libcurl_la-parsedate.o .libs/libcurl_la-select.o
> .libs/libcurl_la-tftp.o .libs/libcurl_la-splay.o
> .libs/libcurl_la-strdup.o .libs/libcurl_la-socks.o
> .libs/libcurl_la-curl_addrinfo.o .libs/libcurl_la-socks_gssapi.o
> .libs/libcurl_la-socks_sspi.o .libs/libcurl_la-curl_sspi.o
> .libs/libcurl_la-slist.o .libs/libcurl_la-nonblock.o
> .libs/libcurl_la-curl_memrchr.o .libs/libcurl_la-imap.o
> .libs/libcurl_la-pop3.o .libs/libcurl_la-smtp.o
> .libs/libcurl_la-pingpong.o .libs/libcurl_la-rtsp.o
> .libs/libcurl_la-curl_threads.o .libs/libcurl_la-warnless.o
> .libs/libcurl_la-hmac.o .libs/libcurl_la-curl_rtmp.o
> .libs/libcurl_la-openldap.o .libs/libcurl_la-curl_gethostname.o
> .libs/libcurl_la-gopher.o .libs/libcurl_la-idn_win32.o
> .libs/libcurl_la-http_proxy.o .libs/libcurl_la-non-ascii.o
> .libs/libcurl_la-asyn-ares.o .libs/libcurl_la-asyn-thread.o
> .libs/libcurl_la-curl_gssapi.o .libs/libcurl_la-http_ntlm.o
> .libs/libcurl_la-curl_ntlm_wb.o .libs/libcurl_la-curl_ntlm_core.o
> .libs/libcurl_la-curl_sasl.o .libs/libcurl_la-rand.o
> .libs/libcurl_la-curl_multibyte.o .libs/libcurl_la-hostcheck.o
> .libs/libcurl_la-conncache.o .libs/libcurl_la-dotdot.o
> .libs/libcurl_la-x509asn1.o .libs/libcurl_la-http2.o
> .libs/libcurl_la-smb.o .libs/libcurl_la-curl_endian.o
> .libs/libcurl_la-curl_des.o .libs/libcurl_la-system_win32.o
> .libs/libcurl_la-mime.o .libs/libcurl_la-sha256.o
> .libs/libcurl_la-setopt.o .libs/libcurl_la-curl_path.o
> .libs/libcurl_la-curl_ctype.o .libs/libcurl_la-curl_range.o
> .libs/libcurl_la-psl.o .libs/libcurl_la-doh.o
> .libs/libcurl_la-urlapi.o .libs/libcurl_la-curl_get_line.o
> .libs/libcurl_la-altsvc.o .libs/libcurl_la-socketpair.o
> vauth/.libs/libcurl_la-vauth.o vauth/.libs/libcurl_la-cleartext.o
> vauth/.libs/libcurl_la-cram.o vauth/.libs/libcurl_la-digest.o
> vauth/.libs/libcurl_la-digest_sspi.o
> vauth/.libs/libcurl_la-krb5_gssapi.o
> vauth/.libs/libcurl_la-krb5_sspi.o vauth/.libs/libcurl_la-ntlm.o
> vauth/.libs/libcurl_la-ntlm_sspi.o vauth/.libs/libcurl_la-oauth2.o
> vauth/.libs/libcurl_la-spnego_gssapi.o
> vauth/.libs/libcurl_la-spnego_sspi.o vtls/.libs/libcurl_la-openssl.o
> vtls/.libs/libcurl_la-gtls.o vtls/.libs/libcurl_la-vtls.o
> vtls/.libs/libcurl_la-nss.o vtls/.libs/libcurl_la-polarssl.o
> vtls/.libs/libcurl_la-polarssl_threadlock.o
> vtls/.libs/libcurl_la-wolfssl.o vtls/.libs/libcurl_la-schannel.o
> vtls/.libs/libcurl_la-schannel_verify.o
> vtls/.libs/libcurl_la-sectransp.o vtls/.libs/libcurl_la-gskit.o
> vtls/.libs/libcurl_la-mbedtls.o vtls/.libs/libcurl_la-mesalink.o
> vquic/.libs/libcurl_la-ngtcp2.o vquic/.libs/libcurl_la-quiche.o
> vssh/.libs/libcurl_la-libssh2.o vssh/.libs/libcurl_la-libssh.o -O2
> -pthread   -pthread `func_echo_all "
> -L/mnt/d/Projects/Xaymar/obs-deps/build/win64/lib -lmbedtls -lmbedx509
> -lmbedcrypto -lz -lws2_32" | /bin/sed 's/ -lc$//'` -link -dll
> /usr/bin/x86_64-w64-mingw32-ld: cannot find -link
> collect2: error: ld returned 1 exit status
I think the problem is the --host= value, but what would be the correct
value for it? I tried mingw64-win32 but it just gave the same result as
x86_64-w64-mingw32.

Sincerely,

Michael Fabian Dirks

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-10-28