help with building hw on windows
Hello! I am trying to discover whether my meager programming skills can be useful to this project. I have many years of boring business app development, mostly in c#, only ancient experience with c++, c and pascal, and the size of this project is quite daunting.
I got vcpkg bootstrapped and the libraries built. (yay!)
When I try to build hw (C:\hg\hedgewars\trunk\tools\build_vcpkg.bat) I am running into "cannot open include file 'SDL.h': no such file or directory".
Digging into this is tough for me (because there are so many layers for me to learn), but I do see a file "C.includecache" (in folder C:\Hg\hedgewars\trunk\misc\libphyslayer\CMakeFiles\physlayer.dir) that was somehow generated with an incorrect folder path for SDL.h:
SDL.h
C:/Hg/hedgewars/trunk/misc/libphyslayer/SDL.h
I am brand new to cmake and nmake, but I am guessing that the problem might be in the CMakeLists.txt file under C:\Hg\hedgewars\trunk\misc\libphyslayer? I see these lines
find_package(SDL2 REQUIRED CONFIG)
include_directories(${SDL2_INCLUDE_DIRS})
which I assume somehow result in setting up the c compiler to look in the right folders for #include....
I figure I am out of my league here, but thought I could at least get this project to compile. And I feel like I am close. But I do not understand what I am doing wrong.
Any help or pointers, or kind words telling me I am oh-so-far from getting it to build, would be appreciated. Thanks in advance!
Hello, sorry for the trouble, I should've updated the build instructions a while ago There have been changes in how vcpkg deploys sdl, here's a patch to make it build https://gist.github.com/alfadur/e8d94701fb4b2145410c2174ff8806fa
There are also changes for sdl2-mixer, it needs to be installed as sdl2-mixer[dynamic-load, libvorbis]. Additionally, after hedgewars installation you'd need to copy over ogg.dll, vorbis.dll and vorbisfile.dll from /installed/x64-windows/bin
Thanks! Worked like a charm. fyi I used
to compile sdl.
I would be happy to update that wiki page, if that would be helpful.
Thanks again for your help!
The plot thickens. It occurred to me that I should actually run the game after it compiled successfully (with all due respect to Linus).
- Launch game, no sound on first screen.
- Start "Basic Movement Training" results in fatal error / game engine had to stop / Mix_Init: OGG support not available.
I'll see if I can figure it out on my own, but any tips, hints, thoughts or best wishes appreciated. And I will postpone updating the KB/wiki on how to build under windows until I can actually get it to work
Unfortunately, I may be away from this for a week.
Yeah, SDL needs libogg. I guess it's just a missing DLL or something so long as it has been built with it on windows?
Linux equiv..
ldd hwengine | grep mixer
libSDL2_mixer-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libSDL2_mixer-2.0.so.0 (0x00007f5cd6bda000)
ldd /usr/lib/x86_64-linux-gnu/libSDL2_mixer-2.0.so.0 | grep ogg
libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f44ccde0000)
--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
@barumpus so that's where manually copying 3 dlls I mentioned before should come in. Unfortunately vcpkg's cmake script doesn't seem to copy over libraries that are dynamically loaded so they end up missing. Probably should just add this to the build script to make things easier
The rest of the build just needs a proper fix that would take care of include dirs, so ultimately the current build instructions should work as is.
Hello!
@xiongmao, my apologies! I do try to avoid making people repeat themselves but in this case I failed to remember that instruction. My excuse is that I was getting a lot of interruptions, but I'm still embarrassed to make you guys spend even more time than you're already kindly doing.
@nemo, the windows equivalent (sort of) is depends.exe (dependency walker). But it's not a very good replacement. According to the webs you are better off just using ldd (available if git is installed, or cygwin, or WSL). (https://stackoverflow.com/a/1993677 and https://stackoverflow.com/a/33019173)
... I saw yesterday that the wiki had been updated and the build had been patched (just minutes beforehand). That's great! It did mean that I couldn't even _pretend_ to be helpful with a pastebin/edit of BuildingOnWindows, but would-be builders are certainly better off with your efforts in place.
fyi I went through the build steps again (clone vcpkg, clone hw, etc), and found two small things --
(1) on BuildingOnWindows the instruction
won't quite work because of the space character in sdl2-mixer[dynamic-load, libvorbis]:x64-windows. It can be fixed just by taking the space out. (ditto for the 32 bit command of course).
(2) because I am my own chaos monkey, I ran into a problem that you guys probably never would
Finally, I have a question about the dynamic libraries. Would you like me to take a whack at changing cmake so that it copies the three DLLs (ogg.dll, vorbis.dll, vorbisfile.dll) to the target folder? Or if not that then a change to the instructions at BuildingOnWindows mentioning the need to do this?
Thanks again for your help! Now that I can build it, I will see if I can actually do anything useful to the project code-wise. (I don't have much hope that I can contribute in a meaningful way, this project is much more complex than anything I've built, but who knows, stranger things have happened. You definitely won't offend or surprise me by telling me at any point that I am as yet a learner only worthy to sweep the floors.) Besides possible lack of skill, I also have a time issue. The rest of my free time today will be spent learning "Flask" (a python-based framework for web apps) for work tomorrow because Friday I learned that there's an app that needs some tweaks, and rewriting it for that seems pretty heavy-handed.
ciao!
Thanks for pointing out the install command typo, it's corrected now
I haven't tried an out of source build on windows before, so not sure it should be recommended as default for now. In most cases deleting CMakeCache.txt is enough to regenerate nmake files. But could add it as an option in the build script.
As for ogg, something along the lines of what OPHD did at https://github.com/OutpostUniverse/OPHD/issues/383#issuecomment-656461289 would be the easiest solution. Would still need to taje care of copying the right dlls for the target architecture though.