afritz1 / OpenTESArena

Open-source re-implementation of The Elder Scrolls: Arena.
MIT License
988 stars 68 forks source link

Compilation error using MSYS2 - 'mem_fn' is not a member of 'std' #82

Closed abelsromero closed 7 years ago

abelsromero commented 7 years ago

Problem: When compiling under Windows (7 and 8.1) with MSYS2 the following error occurs:

.../OpenTESArena/OpenTESArena/src/Media/AudioManager.cpp: In member function 'void OpenALStream::play()':
.../OpenTESArena/OpenTESArena/src/Media/AudioManager.cpp:235:30: error: 'mem_fn' is not a member of 'std'
   mThread = std::thread(std::mem_fn(&OpenALStream::backgroundProc), this);
                              ^~~~~~
.../OpenTESArena/OpenTESArena/src/Media/AudioManager.cpp:235:30: note: suggested alternative: 'mem_fun'
   mThread = std::thread(std::mem_fn(&OpenALStream::backgroundProc), this);
                              ^~~~~~
                              mem_fun
mingw32-make[2]: *** [OpenTESArena/CMakeFiles/TESArena.dir/build.make:2614: OpenTESArena/CMakeFiles/TESArena.dir/src/Media/AudioManager.obj] Error 1
mingw32-make[1]: *** [CMakeFiles/Makefile2:141: OpenTESArena/CMakeFiles/TESArena.dir/all] Error 2
mingw32-make: *** [Makefile:84: all] Error 2

Current solution found: This was easily fixed adding #include <functional> to the file. Some googling suggests this is normal and the error only occurs on some compilers. After that, the game compiles and runs correctly.

env:

afritz1 commented 7 years ago

Looks like an easy fix. I'll probably add that <functional> include tonight.

abelsromero commented 7 years ago

Thanks a lot! Also, I have been trying yo find a easy, stable way to build in Windows without using VS and finally I am quite happy with MSYS2. If you want we can add the process to the readme, or even try to create a script to automate the environment. wdyt?

afritz1 commented 7 years ago

We could think about adding it to the Readme soon. I'm not sure about a script yet, though. Maybe sometime in the future.

afritz1 commented 7 years ago

Hmm, interesting how GitHub automatically closes issues when I say "Fixes #..." in the commit message. If you have any notes about building with MSYS2, leave them here.

abelsromero commented 7 years ago

Here are my notes: https://gist.github.com/abelsromero/778c4a751d2d16b5641ed148c4eb7122

Hmm, interesting how GitHub automatically closes issues when I say "Fixes #..."

See this https://help.github.com/articles/closing-issues-via-commit-messages/

afritz1 commented 7 years ago

That is a nicely formatted build manual! If you make a final draft of it, name it msys2_build_manual.md (or .adoc, I guess), and put it in the docs folder, I'll happily accept a pull request of it. I would put a link to it in the Readme at some point.

abelsromero commented 7 years ago

If you make a final draft of it,

Maybe only some polishing.

or .adoc, I guess

I advocate for the use of AsciiDoc instead of Markdown, but I am happy just introducing it. Now you know there are imho, nicer alternatives. But I will change it to markdown since it's more popular, no problem!

I'll sent a PR during the weekend.