Drewol / unnamed-sdvx-clone

A game based on K-Shoot MANIA and Sound Voltex
MIT License
761 stars 93 forks source link

[Bug] cpr compilation errors when using curl v8 #649

Open gBasil opened 10 months ago

gBasil commented 10 months ago

Describe the bug I'm trying to build unnamed-sdvx-clone via Nix. The version of curl in nixpkgs (the package repo for the Nix ecosystem) is version 8.2.1. When trying to build this project, the following error occurs during the build process:

[ 23%] Building C object third_party/lua-5.3.5/CMakeFiles/lua.dir/src/ltm.c.o
[ 23%] Building C object third_party/lua-5.3.5/CMakeFiles/lua.dir/src/lundump.c.o
[ 23%] Building C object third_party/lua-5.3.5/CMakeFiles/lua.dir/src/lutf8lib.c.o
[ 24%] Building C object third_party/lua-5.3.5/CMakeFiles/lua.dir/src/lvm.c.o
[ 24%] Building C object third_party/lua-5.3.5/CMakeFiles/lua.dir/src/lzio.c.o
[ 25%] Linking C static library /build/source/lib/liblua_Release.a
[ 25%] Built target lua
[ 26%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/auth.cpp.o
[ 26%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/bearer.cpp.o
[ 26%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/cookies.cpp.o
[ 27%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/cprtypes.cpp.o
[ 27%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/curl_container.cpp.o
[ 28%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/curlholder.cpp.o
/build/source/third_party/cpr/cpr/curlholder.cpp: In destructor 'cpr::CurlHolder::~CurlHolder()':
/build/source/third_party/cpr/cpr/curlholder.cpp:26:18: error: 'void curl_formfree(curl_httppost*)' is deprecated: since 7.56.0. Use curl_mime_free() [-Werror=deprecated-declarations]
   26 |     curl_formfree(formpost);
      |     ~~~~~~~~~~~~~^~~~~~~~~~
In file included from /build/source/third_party/cpr/include/cpr/curlholder.h:8,
                 from /build/source/third_party/cpr/cpr/curlholder.cpp:1:
/nix/store/md841pq8jws8gd4nx6hlyvgvbsj1hbv7-curl-8.2.1-dev/include/curl/curl.h:2621:1: note: declared here
 2621 | curl_formfree(struct curl_httppost *form);
      | ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [third_party/cpr/cpr/CMakeFiles/cpr.dir/build.make:146: third_party/cpr/cpr/CMakeFiles/cpr.dir/curlholder.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:525: third_party/cpr/cpr/CMakeFiles/cpr.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

This issue seems to have been fixed in a recent version of cpr. See: https://github.com/libcpr/cpr/issues/870 https://github.com/libcpr/cpr/pull/890

However, forking this repository, updating the cpr submodule, pointing the flake to use the fork as an input, and trying to build gives the following error:

[ 68%] Building CXX object Beatmap/CMakeFiles/Beatmap.dir/src/KShootMap.cpp.o
[ 69%] Building CXX object Beatmap/CMakeFiles/Beatmap.dir/src/LineGraph.cpp.o
[ 69%] Building CXX object Beatmap/CMakeFiles/Beatmap.dir/src/MapDatabase.cpp.o
[ 69%] Building CXX object Beatmap/CMakeFiles/Beatmap.dir/src/PlaybackOptions.cpp.o
[ 70%] Building CXX object Beatmap/CMakeFiles/Beatmap.dir/stdafx.cpp.o
[ 70%] Linking CXX static library /build/source/lib/libBeatmap_Release.a
[ 70%] Built target Beatmap
[ 70%] Building CXX object Main/CMakeFiles/usc-game.dir/src/Application.cpp.o
In file included from /build/source/third_party/glew/include/GL/glxew.h:98,
                 from /build/source/Graphics/include/Graphics/GL.hpp:21,
                 from /build/source/Main/./stdafx.h:5,
                 from /build/source/Main/src/Application.cpp:1:
/build/source/third_party/cpr/include/cpr/threadpool.h:96:10: error: expected identifier before 'int'
   96 |     enum Status {
      |          ^~~~~~
In file included from /build/source/third_party/cpr/include/cpr/async.h:6,
                 from /build/source/third_party/cpr/include/cpr/api.h:10,
                 from /build/source/third_party/cpr/include/cpr/cpr.h:4,
                 from /build/source/Main/./stdafx.h:60:
/build/source/third_party/cpr/include/cpr/threadpool.h:96:17: error: expected unqualified-id before '{' token
   96 |     enum Status {
      |                 ^
/build/source/third_party/cpr/include/cpr/threadpool.h: In member function 'bool cpr::ThreadPool::IsStarted()':
/build/source/third_party/cpr/include/cpr/threadpool.h:47:26: error: 'STOP' was not declared in this scope
   47 |         return status != STOP;
      |                          ^~~~
/build/source/third_party/cpr/include/cpr/threadpool.h: In member function 'bool cpr::ThreadPool::IsStopped()':
/build/source/third_party/cpr/include/cpr/threadpool.h:50:26: error: 'STOP' was not declared in this scope
   50 |         return status == STOP;
      |                          ^~~~
/build/source/third_party/cpr/include/cpr/threadpool.h: In member function 'auto cpr::ThreadPool::Submit(Fn&&, Args&& ...)':
/build/source/third_party/cpr/include/cpr/threadpool.h:67:23: error: 'STOP' was not declared in this scope
   67 |         if (status == STOP) {
      |                       ^~~~
make[2]: *** [Main/CMakeFiles/usc-game.dir/build.make:76: Main/CMakeFiles/usc-game.dir/src/Application.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:643: Main/CMakeFiles/usc-game.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

To Reproduce Steps to reproduce the behavior:

  1. Install Nix and enable Flakes
  2. Create some folder
  3. Create a file called flake.nix with the following content:

    {
    inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    };
    
    outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import nixpkgs {
        inherit system;
      };
    in {
      packages.default = pkgs.stdenv.mkDerivation {
        name = "unnamed-sdvx-clone";
    
        src = pkgs.fetchFromGitHub {
          owner = "Drewol";
          repo = "unnamed-sdvx-clone";
          rev = "7895040479b560c98df19ad86424b2ce169afd82"; # Latest commit (the latest tagged version is from 2021)
          sha256 = "sha256-23j0B0cLMz3vFxfGcNphukoc/koz1z+qNYHnemre0o8=";
          fetchSubmodules = true;
        };
    
        nativeBuildInputs = with pkgs; [
          cmake
        ];
    
        cmakeFlags = [
          # If this flag is not enabled, the cpr CMakeLists.txt will try and clone zlib with git at buildtime, which will error out, as the network is disabled during Nix package builds
          "-DCPR_FORCE_USE_SYSTEM_CURL=ON"
        ];
    
        buildPhase = ''
          make
        '';
    
        installPhase = ''
                mkdir -p $out/bin
          mv bin $out/bin
        '';
    
        buildInputs = with pkgs; [
          SDL2
          zlib
          freetype
          libarchive
          libogg
          libvorbis
          libpng # orig is libpng12
          libjpeg # orig is libjpeg_original
    
          # rapidjson # required by third_party/discord-rpc
    
          # libgl1-mesa-dev # not sure where to pull this from or if I even need to at this point?
    
          openssl
          libiconv
    
          curl # See the explanation for forcing system curl
        ];
      };
    }
    );
    }
  4. Run nix build
  5. See error

Desktop:

SkyLeite commented 6 months ago

This was fixed in 76c359fe04eaed04fa4547b509473db619ab595b

ixhbinphoenix commented 1 month ago

Unfortunately this error still occurs on then newest commit (f264d38), now with curl 8.7.1 but the exact same issue.

[ 28%] Building CXX object third_party/cpr/cpr/CMakeFiles/cpr.dir/curlholder.cpp.o
/build/source/third_party/cpr/cpr/curlholder.cpp: In destructor 'cpr::CurlHolder::~CurlHolder()':
/build/source/third_party/cpr/cpr/curlholder.cpp:26:18: error: 'void curl_formfree(curl_httppost*)' is deprecated: since 7.56.0. Use curl>
   26 |     curl_formfree(formpost);
      |     ~~~~~~~~~~~~~^~~~~~~~~~
In file included from /build/source/third_party/cpr/include/cpr/curlholder.h:8,
                 from /build/source/third_party/cpr/cpr/curlholder.cpp:1:
/nix/store/cnazciv4gza3ylaaa2yqfz9nivnqhlh4-curl-8.7.1-dev/include/curl/curl.h:2617:1: note: declared here
 2617 | curl_formfree(struct curl_httppost *form);
      | ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [third_party/cpr/cpr/CMakeFiles/cpr.dir/build.make:146: third_party/cpr/cpr/CMakeFiles/cpr.dir/curlholder.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:525: third_party/cpr/cpr/CMakeFiles/cpr.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

This is the flake I use:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import nixpkgs {
        inherit system;
      };
    in {
      packages.default = pkgs.stdenv.mkDerivation {
        name = "unnamed-sdvx-clone";

        src = pkgs.fetchFromGitHub {
          owner = "Drewol";
          repo = "unnamed-sdvx-clone";
          rev = "f264d380dd0550a781237028392e68db1ec51478"; # Latest commit (the latest tagged version is from 2021)
          sha256 = "sha256-UgdBiASCUbF+UtxgJ0UMH7d1zOKW/y3bXGkAKB/cBEk=";
          fetchSubmodules = true;
        };

        nativeBuildInputs = with pkgs; [
          cmake
        ];

        cmakeFlags = [
          # If this flag is not enabled, the cpr CMakeLists.txt will try and clone zlib with git at buildtime, which will error out, as the network is disabled during Nix package builds
          "-DCPR_FORCE_USE_SYSTEM_CURL=ON"
        ];

        buildPhase = ''
          make
        '';

        installPhase = ''
                mkdir -p $out/bin
          mv bin $out/bin
        '';

        buildInputs = with pkgs; [
          SDL2
          zlib
          freetype
          libarchive
          libogg
          libvorbis
          libpng # orig is libpng12
          libjpeg # orig is libjpeg_original

          # rapidjson # required by third_party/discord-rpc

          # libgl1-mesa-dev # not sure where to pull this from or if I even need to at this point?

          openssl
          libiconv

          curl # See the explanation for forcing system curl
        ];
      };
    }
  );
}