ZDoom / gzdoom

GZDoom is a feature centric port for all Doom engine games, based on ZDoom, adding an OpenGL renderer and powerful scripting capabilities
http://zdoom.org
GNU General Public License v3.0
2.47k stars 540 forks source link

[BUG] Cannot compile on Fedora 40 #2530

Closed hfc2x closed 5 months ago

hfc2x commented 5 months ago

GZDoom version

GZDoom 4.12.1 and eba9036

Which game are you running with GZDoom?

Doom 2

What Operating System are you using?

Linux x86_64

Please describe your specific OS version

Fedora 40

Relevant hardware info

No response

Have you checked that no other similar issue already exists?

A clear and concise description of what the bug is.

GZDoom cannot compile on Fedora 40, after upgrade from Fedora 39, where it compiled fine. Applies to both the latest stable version (4.12.1 at the time of writing) and the latest commit.

Followed all the instructions here, including installing all the required dependencies along with ZMusic, but compiler stops with the following error when making GZDoom itself:

/home/[user]/gzdoom_build/gzdoom/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp: In member function ‘virtual void LineEdit::OnKeyDown(EInputKey)’:
/home/[user]/gzdoom_build/gzdoom/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp:509:76: error: cannot convert ‘std::__cxx11::basic_string<char>::iterator’ to ‘const char*’
  509 |                 std::string::const_iterator end_str = std::remove(str.begin(), str.end(), '\n');
      |                                                                   ~~~~~~~~~^~
      |                                                                            |
      |                                                                            std::__cxx11::basic_string<char>::iterator
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /home/[user]/gzdoom_build/gzdoom/libraries/ZWidget/include/zwidget/widgets/lineedit/../../core/widget.h:3,
                 from /home/[user]/gzdoom_build/gzdoom/libraries/ZWidget/include/zwidget/widgets/lineedit/lineedit.h:4,
                 from /home/[user]/gzdoom_build/gzdoom/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp:2:
/usr/include/stdio.h:158:32: note:   initializing argument 1 of ‘int remove(const char*)’
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~
/home/[user]/gzdoom_build/gzdoom/libraries/ZWidget/src/widgets/lineedit/lineedit.cpp:511:48: error: cannot convert ‘std::__cxx11::basic_string<char>::iterator’ to ‘const char*’
  511 |                 end_str = std::remove(str.begin(), str.end(), '\r');
      |                                       ~~~~~~~~~^~
      |                                                |
      |                                                std::__cxx11::basic_string<char>::iterator
/usr/include/stdio.h:158:32: note:   initializing argument 1 of ‘int remove(const char*)’
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~

Steps to reproduce the behaviour.

Explain how to reproduce

  1. Download the source
  2. Install all the required dependencies
  3. Run the commands listed in the wiki

Your configuration

No response

Provide a Log

No response

madame-rachelle commented 5 months ago

Have you reported this to the GCC and Fedora devs? That should always be your first point of contact when something is so specific to a compiler like this.

hfc2x commented 5 months ago

I was about to do just that now, when I actually stumbled upon the documentation for GCC 14, which is what Fedora 40 uses.

It states here:

Header dependency changes

Some C++ Standard Library headers have been changed to no longer include other headers that were being used internally by the library. As such, C++ programs that used standard library components without including the right headers will no longer compile.

The following headers are used less widely in libstdc++ and may need to be included explicitly when compiling with GCC 14:

  • <algorithm> (for std::copy_n, std::find_if, std::lower_bound, std::remove, std::reverse, std::sort etc.)
  • <cstdint> (for std::int8_t, std::int32_t etc.)

So, I went and modified both /libraries/ZWidget/src/widgets/lineedit/lineedit.cpp and /src/common/filesystem/source/resourcefile.cpp to add #include <algorithm> to both of them, and it now compiles without issue.

I have no idea if changing these will actually break compilation for other distros, though.

madame-rachelle commented 5 months ago

I have no idea if changing these will actually break compilation for other distros, though.

Adding simple system includes is incredibly unlikely to cause issues with compiling in other distros. :) If these 2 changes are all that's needed it should be safe to do move forward with just those and hope they don't do anything else arbitrary.

madame-rachelle commented 5 months ago

fixed