m-ab-s / media-autobuild_suite

This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.
GNU General Public License v3.0
1.51k stars 262 forks source link

[mingw64] [curl] configure: error: one or more libs available at link-time are not available run-time #2441

Open voltagex opened 1 year ago

voltagex commented 1 year ago

logs.zip Building from 663087e596f4fe2ddab9031a7ca602d1f5485f0c

14:48:11 ┌ curl git  ................................. [Recently updated]
14:48:12 ├ Installing nghttp2... done
14:48:13 ├ Running autoreconf...
14:48:38 ├ Running configure...
Likely error (tail of the failed operation logfile):
checking for an ANSI C-conforming const... yes
checking for compiler support of C99 variadic macro style... yes
checking for compiler support of old gcc variadic macro style... yes
checking for size_t... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/socket.h... (cached) no
checking for struct timeval... yes
checking run-time libs availability... failed
configure: error: one or more libs available at link-time are not available run-time. Libs used at link-time: -lnghttp2  -lidn2 -liconv  -lpsl -lidn2 -liconv  -lbcrypt -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lws2_32 -lgdi32 -lcrypt32 -lcrypto -lws2_32 -lgdi32 -lcrypt32  -lgdi32 -lwldap32 -lzstd  -lbrotlidec -lbrotlidec -lbrotlicommon  -lz -lws2_32
configure failed. Check C:/git/media-autobuild_suite/build/curl-git/build-64bit/ab-suite.configure.log
This is required for other packages, so this script will exit.
14:55:17   Creating diagnostics file...

Attach C:\git\media-autobuild_suite\build\logs.zip to the GitHub issue.
Make sure the suite is up-to-date before reporting an issue. It might've been fixed already.

Try running the build again at a later time.
voltagex commented 1 year ago

Setting curl=2 in the .ini doesn't appear to fix this

Selur commented 1 year ago

Same here with 32bit:

(deleting curl-git folder didn't help) logs.zip

Biswa96 commented 1 year ago

It seems that the issue is not related to the curl or mabs project. The config.log file has multiple errors with gcc.exe: fatal error: no input files message. So, something probably removed the source file, like conftest.c. It is generated temporarily by configure script.

Can anyone check if excludinga the media-autobuild_suite project directory or the local64 directory in Windows Defender (or in any antivirus program) fixes the issue?

voltagex commented 1 year ago

@Biswa96 I temporarily turned off real time protection in Defender before trying this build.

waldonnis commented 1 year ago

I reverted https://github.com/curl/curl/pull/11120 and it allowed curl to build. I haven't looked at what went wrong there yet or the reason for the change, so I don't have any suggestions on what would fix both our issue and the original reason for that PR.

Biswa96 commented 1 year ago

I've compiled curl with the same configure options from OP's log file in msys2/mingw-w64. It worked fine.

hydra3333 commented 1 year ago

Setting curl=2 in the .ini doesn't appear to fix this

Me too. Perhaps it's as a dependency lib being built.

waldonnis commented 1 year ago

I've compiled curl with the same configure options from OP's log file in msys2/mingw-w64. It worked fine.

There is also the CPPFLAGS var being passed to configure by media-suite_compile.sh: CPPFLAGS+=" -DGNUTLS_INTERNAL_BUILD -DNGHTTP2_STATICLIB -DPSL_STATIC"

Without that, the configure script finishes fine for me as well, but died with the same error as above when I prefaced configure with it as is done in media-suite_compile.sh. I may know what's going on, but I'll poke at it tomorrow after some much needed sleep.

** edit: Figured it out. It was broken even without the CPPFLAGS, but in a less obvious way. I'll post a patch after my test build finishes.

waldonnis commented 1 year ago

Okay, the build seems to have completed fine...

It turned out to be a var quoting issue that didn't really show up unless the value of CC and/or LD_LIBRARY_PATH contained a space. When "CC=ccache gcc", for example, CC just gets set to "ccache", which obviously would break the tests using this wrapper. Quoting those values properly in the run-compiler script (or really in the creation of those lines for the script) allows the vars to be set properly and all works fine.

Note that I also tweaked the LD_LIBRARY_PATH override, since if it had no value prior and CURL_LIBRARY_PATH was also empty, it would assign just ":" which caused a problem while I was testing a different issue unrelated to this. Lastly, I re-exported the restored LD_LIBRARY_PATH after the test run to ensure that it's properly restored globally (this was more of a "just to be safe"; never saw an obvious issue before doing this, but I wasn't looking for one and it seemed prudent to formally undo the previous export).

See if this makes sense and works for you and if so, feel free to submit it to the curl folks if I don't get to it before you do.

diff --git a/configure.ac b/configure.ac
index 75a882b12..9a522e917 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,8 +193,8 @@ dnl something different but only have that affect the execution of the results
 dnl of the compile, not change the libraries for the compiler itself.
 dnl
 compilersh="run-compiler"
-echo "CC=$CC" > $compilersh
-echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $compilersh
+echo "CC='$CC'" > $compilersh
+echo "LD_LIBRARY_PATH='$LD_LIBRARY_PATH'" >> $compilersh
 echo 'exec $CC $@' >> $compilersh

 dnl **********************************************************************
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4
index bd2ebbd01..08ac10e10 100644
--- a/m4/curl-functions.m4
+++ b/m4/curl-functions.m4
@@ -5869,10 +5869,15 @@ AC_DEFUN([CURL_RUN_IFELSE], [
       oldcc=$CC
       old=$LD_LIBRARY_PATH
       CC="sh ./run-compiler"
-      LD_LIBRARY_PATH=$CURL_LIBRARY_PATH:$old
+      if test -z "$LD_LIBRARY_PATH"; then
+        LD_LIBRARY_PATH=$CURL_LIBRARY_PATH
+      else
+        LD_LIBRARY_PATH="$CURL_LIBRARY_PATH:$old"
+      fi
       export LD_LIBRARY_PATH
       AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4)
       LD_LIBRARY_PATH=$old # restore
+      export LD_LIBRARY_PATH
       CC=$oldcc
      ;;
    esac
hydra3333 commented 1 year ago

a query: how to apply those diffs as a patch in media-suite_compile.sh ?

_edit: ok, I put a temporary copy of the patch at this point in media-suite_compile.sh and it seemed to build._

    case $curl in
    libressl|openssl)
        extra_opts+=(--with-{nghttp2,openssl} --without-{gnutls,mbedtls})
        ;;
    mbedtls) extra_opts+=(--with-{mbedtls,nghttp2} --without-openssl) ;;
    gnutls) extra_opts+=(--with-gnutls --without-{nghttp2,mbedtls,openssl}) ;;
    *) extra_opts+=(--with-{schannel,winidn,nghttp2} --without-{gnutls,mbedtls,openssl});;
    esac

    do_patch "https://raw.githubusercontent.com/hydra3333/h3333_python_cross_compile_script_v100/master/patches/mabs_curl/mabs_curl.patch"

    [[ ! -f configure || configure.ac -nt configure ]] &&
        do_autoreconf
    [[ $curl = openssl ]] && hide_libressl
1480c1 commented 1 year ago

Do you guys still see this issue even after https://github.com/curl/curl/commit/471dab2da0c6b2b08ca2b96a1da0a4825e2c3c36, https://github.com/curl/curl/commit/c4a019603b82a08c3572591a9393df0818ee02f6, and https://github.com/curl/curl/commit/5a023938fa5ed444074c78dc345c7c987e570a55? I haven't been able to reproduce this anytime recent