premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.2k stars 618 forks source link

undefined reference to `__imp_CertFreeCertificateContext' when building under MSYS2 #1870

Open trolzen opened 2 years ago

trolzen commented 2 years ago

I'm trying to build premake-5.0.0-beta1-src under MSYS2 but get this linking error:

zheka@hydra MINGW64 /c/projects/premake5/premake-5.0.0-beta1-src/build/gmake2.windows
$ make Premake5
==== Building lua-lib (release_win32) ====
==== Building zip-lib (release_win32) ====
==== Building zlib-lib (release_win32) ====
==== Building curl-lib (release_win32) ====
==== Building Premake5 (release_win32) ====
Linking Premake5
../../src/host/curl_utils.c: In function 'curlRequest':
../../src/host/curl_utils.c:179:9: warning: call to '_curl_easy_setopt_err_write_callback' declared with attribute warning: curl_easy_setopt expects a curl_write_callback argument for this option [-Wattribute-warning]
  179 |         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlWriteCallback);
      |         ^
../../src/host/curl_utils.c:185:17: warning: call to '_curl_easy_setopt_err_progress_cb' declared with attribute warning: curl_easy_setopt expects a curl_progress_callback argument for this option [-Wattribute-warning]
  185 |                 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curlProgressCallback);
      |                 ^
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccojyC5r.ltrans10.ltrans.o:<artificial>:(.text+0x1843): undefined reference to `__imp_CertFreeCertificateContext'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccojyC5r.ltrans10.ltrans.o:<artificial>:(.text+0x1c8a): undefined reference to `__imp_CertFreeCertificateContext'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccojyC5r.ltrans10.ltrans.o:<artificial>:(.text+0x1d95): undefined reference to `__imp_CertFreeCertificateContext'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Premake5.make:183: ../../bin/release/premake5.exe] Error 1
make: *** [Makefile:50: Premake5] Error 2

However, if I add libcrypt32 to LIBS the build succeeds:

user@host MINGW64 /c/projects/premake5/premake-5.0.0-beta1-src/build/gmake2.windows
$ LIBS=-lcrypt32 make Premake5
==== Building lua-lib (release_win32) ====
==== Building zip-lib (release_win32) ====
==== Building zlib-lib (release_win32) ====
==== Building curl-lib (release_win32) ====
==== Building Premake5 (release_win32) ====
Linking Premake5
../../src/host/curl_utils.c: In function 'curlRequest':
../../src/host/curl_utils.c:179:9: warning: call to '_curl_easy_setopt_err_write_callback' declared with attribute warning: curl_easy_setopt expects a curl_write_callback argument for this option [-Wattribute-warning]
  179 |         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlWriteCallback);
      |         ^
../../src/host/curl_utils.c:185:17: warning: call to '_curl_easy_setopt_err_progress_cb' declared with attribute warning: curl_easy_setopt expects a curl_progress_callback argument for this option [-Wattribute-warning]
  185 |                 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curlProgressCallback);
      |                 ^

user@host MINGW64 /c/projects/premake5/premake-5.0.0-beta1-src/build/gmake2.windows
$ ../../bin/release/premake5.exe --version
premake5 (Premake Build Script Generator) 5.0.0-beta1

Looks like this library was forgotten at some point. Or is this only relevant to MSYS2 and not for other MinGW-related environments?

nickclark2016 commented 2 years ago

Is this happening with the Bootstrap files or the files generated by running Premake?

trolzen commented 2 years ago

It happens when I build using the generated files of source release inside the build/gmake2.windows directory.

samsinsane commented 2 years ago

We don't assume --cc=mingw when running gmake2 with --os=windows - I'm not sure what the expected environment is. This is the line that generates that directory: https://github.com/premake/premake-core/blob/6b8cabad1640ee7fa2cefbc1a526afbb859d393f/scripts/package.lua#L215

I'm not aware of any other situation where you'd use a "GNU Makefile" on Windows other than with MinGW (or the alternatives), perhaps gmake2.windows should assume mingw?