ciplogic / fheroes2enh

Free Heroes 2 - Enhanced
Other
134 stars 19 forks source link

Cannot build due to missing SDL headers #17

Closed HiPhish closed 5 years ago

HiPhish commented 5 years ago

I'm trying to build this engine, but I get errors about missing SDL headers. Here is how I invoke the build process:

cd /path/to/repo/fheroes2enh-1.01
cmake .
make

The error I get is

/path/to/repo/fheroes2enh-1.01/src/engine/audio_mixer.cpp:49:10: fatal error: SDL_mixer.h: No such file or directory
 #include "SDL_mixer.h"
          ^~~~~~~~~~~~~
compilation terminated.

I looked into the offending line and the issue is the way the file is being included:

#include "SDL_mixer.h"

I have to change it to

#include <SDL/SDL_mixer.h>

to get it to find the header.

I am a C person, not a C++ person, but I always thought including headers worked the same in both. The former inclusion instructs the compiler to search for the header in the same directory as the source file, while the latter instructs the compiler to search for a file named SDL_mixer.h in a directory named SDL, which is in some standard location the compiler knows about.

What is the reason for using your strange way of including the headers of a library? Or did I invoke the build process wrongly?

kamiccolo commented 5 years ago

Could You please provide more details on Your build environment?

HiPhish commented 5 years ago

Yes. I'm running Kubuntu 18.04, but the build environment is set up via Guix:

guix environment fheroes2-enh

Guix is a functional package manager, what this effectively means is that the packages you build do not depend on what's installed on your system, but what you tell it to build with; Guix will build the dependencies and symlink everything without altering your system. Here is my definition:

(define-public fheroes2-enh
  (package
    (name "fheroes2-enh")
    (version "1.01")
    (source
      (origin
        (method url-fetch)
        (uri (string-append "https://github.com/ciplogic/fheroes2enh/archive/"
                            version
                            ".tar.gz"))
        (sha256
          (base32 "12c6lfjyij6f1pw7773msvxpf8gpiy3rm4i9pj2s6nnwpq2zwwh1"))))
    (build-system cmake-build-system)
    (inputs
      `(("sdl" ,sdl)
        ("sdl-image" ,sdl-image)
        ("sdl-mixer" ,sdl-mixer)
        ("sdl-ttf" ,sdl-ttf)))

It reads a bit like JSON, but it's Scheme source code. The important part is the inputs, these are the dependencies I have specified explicitly, only SDL and related.

After changing all the includes I was able to compile everything; I have yet to try to run it, but at least the compiler is satisfied.

kamiccolo commented 5 years ago

Well, it does not say anything about the installed package and it's file layout in the container (I'm presuming guix is using something like that).

kamiccolo commented 5 years ago

But yeah,

 #include <SDL/SDL_mixer.h>

seems like a proper way to go.

HiPhish commented 5 years ago

Everything is pretty much in the usual location, e.g. $GUIX_ENVIRONMENT/include/SDL/SDL_mixer.h (where $GUIX_ENVIRONMENT is the path the the "container"). It should be the same as installing everything globally on the system via sudo apt install sdl sdl-mixer ..., and the fact that it compiles leads me to believe that it is.

alezost commented 5 years ago

Hello @HiPhish,

This is a common problem Guix faces with SDL project. Usually it is workarounded on the Guix side by using sdl-union in the package definition. You may look at multiple examples of it in (gnu packages games) module. The following package "works" for me:

(define-public fheroes2-enh
  (package
    (name "fheroes2-enh")
    (version "1.01")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/ciplogic/fheroes2enh/archive/"
                           version ".tar.gz"))
       (sha256
        (base32 "12c6lfjyij6f1pw7773msvxpf8gpiy3rm4i9pj2s6nnwpq2zwwh1"))))
    (build-system cmake-build-system)
    (arguments
     '(#:tests? #f              ; there are no tests
       #:make-flags
       (list (string-append "CPATH="
                            (assoc-ref %build-inputs "sdl-union")
                            "/include/SDL"))))
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (inputs
     `(("sdl-union" ,(sdl-union (list sdl sdl-mixer sdl-image sdl-ttf)))))
    (home-page "https://github.com/ciplogic/fheroes2enh")
    (synopsis "Enhanced version of Free Heroes 2 engine")
    (description "@code{Free Heroes 2} is an engine recreation of the
game @code{Heroes of Might and Magic 2}.  This package is a clone of the
original @code{Free Heroes 2} engine with user interface and coding
enhancements.")
    (license license:gpl2+)))

By "works" I mean guix build fheroes2-enh builds it successfully, however it fails on install phase because there is no install target (see issue 16).

ciplogic commented 5 years ago

As for me, I can give anyone write access to update build and paths, and when the work is complete on a branch, I will adjust the Windows code to use adjusted paths and merge it into master

ciplogic commented 5 years ago

No feedback for more than 6 months. Closing the issue.