help with building hw on windows

7 replies [Last post]
barumpus
User offline. Last seen 4 years 16 weeks ago. Offline
Joined: 2020-08-29
Posts: 4

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:

Quote:

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

Quote:

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!

xiongmao
User offline. Last seen 16 weeks 6 days ago. Offline
Joined: 2018-11-03
Posts: 15

Hello, sorry for the trouble, I should've updated the build instructions a while ago Smile 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

barumpus
User offline. Last seen 4 years 16 weeks ago. Offline
Joined: 2020-08-29
Posts: 4

Thanks! Worked like a charm. fyi I used

vcpkg install "sdl2-mixer[dynamic-load, libvorbis]:x64-windows"

to compile sdl. 

I would be happy to update that wiki page, if that would be helpful.

  • simple enough to change the vcpkg install commands ... unless I should verify the 32-bit instructions first using a VM... I guess that would still be simple just a chore (:
  • I can include a link to your patch (gist) and instructions for hg newbies (like me) on getting it applied. (I know git pretty well but I am brand new to hg) ...I probably did it wrong or in a dumb way (: so my wiki edits, if you want them, should probably be approved/reviewed.

Thanks again for your help!

barumpus
User offline. Last seen 4 years 16 weeks ago. Offline
Joined: 2020-08-29
Posts: 4

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 Wink Smiley

Unfortunately, I may be away from this for a week.

nemo
nemo's picture
User offline. Last seen 25 weeks 26 min ago. Offline
Joined: 2009-01-28
Posts: 1861

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

xiongmao
User offline. Last seen 16 weeks 6 days ago. Offline
Joined: 2018-11-03
Posts: 15

@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 Smile
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.

barumpus
User offline. Last seen 4 years 16 weeks ago. Offline
Joined: 2020-08-29
Posts: 4

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.
Wink Smiley

fyi I went through the build steps again (clone vcpkg, clone hw, etc), and found two small things --

(1) on BuildingOnWindows the instruction

Quote:

.\vcpkg.exe install sdl2:x64-windows sdl2-image:x64-windows sdl2-ttf:x64-windows sdl2-mixer[dynamic-load, libvorbis]:x64-windows sdl2-net:x64-windows physfs:x64-windows openssl:x64-windows qt5-base:x64-windows qt5-tools:x64-windows ffmpeg:x64-windows

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

  1. Had too many terminals open for my brain, and ran build_vcpkg.bat in a normal terminal rather than the "x64 native tools visual studio" cmd prompt. This of course didn't work but I didn't realize (being new to cmake) it created some cmake cache files that would spoil things.
  2. I switched to the right window, ran build_vcpkg.bat, and encountered errors that had me scratching my head for a bit. (The first of which was C:\FPC\3.2.0\bin\i386-win32\ld.exe: cannot find /nologo: No such file or directory.)
  3. I understood of course that this was the wrong linker, but it was a mystery to me as to how cmake was deciding it should be using that linker. I starting learning stuff about cmake and VS x64 command prompt, etc. (That's a good thing of course but I think not the ideal way to start.) Eventually I just searched for for "ld.exe" and found it in a "CMakeCache.txt".
  4. I deleted the file, but was (incorrectly) sure that it would just get recached with the wrong info. When it got rebuilt correctly I was confused. Late last night just before falling asleep I had the inspiration to remember that I had set the stage for the puzzle in step A above.
So this morning I looked for the proper way to do a cmake "clean". According to the webs, the best way to do this is to use a "build" folder in the same directory as the root "CMakeLists.txt" file, a so-called "out of source build". You guys are probably already aware of this term. Anyway, for newbs like me, I was wondering what you think of having the steps at BuildingOnWindows specifically recommend this approach? (e.g.
Quote:
in trunk directory, create 'build' subdirectory (or delete and recreate it), then run cd build && cmake ..
) https://stackoverflow.com/a/9680493

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!

xiongmao
User offline. Last seen 16 weeks 6 days ago. Offline
Joined: 2018-11-03
Posts: 15

Thanks for pointing out the install command typo, it's corrected now Smile
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.

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]