shonumi / gbe-plus

DMG/GBC/GBA emulator and experimental NDS emulator.
GNU General Public License v2.0
530 stars 80 forks source link

Compilation for Windows broken #135

Open RivenSkaye opened 1 year ago

RivenSkaye commented 1 year ago

Due to commit this commit adding two setenv calls, compilation under Windows through MSYS2 is currently broken. GCC asks if the user meant getenv, but on Windows it seems the correct call is putenv, which only takes a single string in the format "KEY=VALUE". Error:

FAILED: src/common/CMakeFiles/common.dir/config.cpp.obj
C:\msys64\mingw64\bin\c++.exe -DGBE_GLEW -DGBE_NETPLAY -DGBE_OGL -DGBE_QT_5 -IC:/msys64/mingw64/include/SDL2 -IC:/msys64/home/Riven/Projects/gbe-plus/src/. -O3 -funroll-loops
 -Wno-error -Wno-narrowing -std=c++17 -MD -MT src/common/CMakeFiles/common.dir/config.cpp.obj -MF src\common\CMakeFiles\common.dir\config.cpp.obj.d -o src/common/CMakeFiles/c
ommon.dir/config.cpp.obj -c C:/msys64/home/Riven/Projects/gbe-plus/src/common/config.cpp
C:/msys64/home/Riven/Projects/gbe-plus/src/common/config.cpp: In function 'bool parse_cli_args()':
C:/msys64/home/Riven/Projects/gbe-plus/src/common/config.cpp:793:41: error: 'setenv' was not declared in this scope; did you mean 'getenv'?
  793 |                                         setenv("SDL_AUDIODRIVER", config::override_audio_driver.c_str(), 1);
      |                                         ^~~~~~
      |                                         getenv
C:/msys64/home/Riven/Projects/gbe-plus/src/common/config.cpp: In function 'bool parse_ini_file()':
C:/msys64/home/Riven/Projects/gbe-plus/src/common/config.cpp:1848:41: error: 'setenv' was not declared in this scope; did you mean 'getenv'?
 1848 |                                         setenv("SDL_AUDIODRIVER", config::override_audio_driver.c_str(), 1);
      |                                         ^~~~~~
      |                                         getenv

Mangling that so it works:tm: proceeds to cause issues from src/gba/am3.cpp, in regards to a conversion from a filesystem path to a string. I can't seem to find the commit causing this one:

FAILED: src/gba/CMakeFiles/gba.dir/am3.cpp.obj
C:\msys64\mingw64\bin\c++.exe -DGBE_GLEW -DGBE_NETPLAY -DGBE_OGL -DGBE_QT_5 -IC:/msys64/mingw64/include/SDL2 -IC:/msys64/home/Riven/Projects/gbe-plus/src/. -O3 -funroll-loops
 -Wno-error -Wno-narrowing -std=c++17 -MD -MT src/gba/CMakeFiles/gba.dir/am3.cpp.obj -MF src\gba\CMakeFiles\gba.dir\am3.cpp.obj.d -o src/gba/CMakeFiles/gba.dir/am3.cpp.obj -c
 C:/msys64/home/Riven/Projects/gbe-plus/src/gba/am3.cpp
C:/msys64/home/Riven/Projects/gbe-plus/src/gba/am3.cpp: In member function 'bool AGB_MMU::am3_load_folder(std::string)':
C:/msys64/home/Riven/Projects/gbe-plus/src/gba/am3.cpp:414:52: error: conversion from 'const std::filesystem::__cxx11::path' to non-scalar type 'std::string' {aka 'std::__cxx
11::basic_string<char>'} requested
  414 |                 std::string f_name = fs_files->path();
      |                                      ~~~~~~~~~~~~~~^~
C:/msys64/home/Riven/Projects/gbe-plus/src/gba/am3.cpp:415:63: error: conversion from 'std::filesystem::__cxx11::path' to non-scalar type 'std::string' {aka 'std::__cxx11::ba
sic_string<char>'} requested
if (USE_OGL)
  415 |                 std::string s_name = fs_files->path().filename();
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~
RivenSkaye commented 3 months ago

Okay so I retried building it considering I had some spare time. Still on a Windows 10/MSYS2 environment, using the MinGW64 shell env. Required some additional package installation and I ended up getting this combination to work:

# Group them by package family, sort of.
# Yes, the Qt selection there is the rather bloated full qt5 collection package. The README does not
# list which components are actually used or required for the GUI.
pacman -Sy mingw-w64-x86_64-glew mingw-w64-x86_64-SDL2_{gfx,image,mixer,net,sound,ttf} mingw-w64-x86_64-{gles-headers,ftgl} mingw-w64-x86_64-glfw mingw-w64-x86_64-angleproject mingw-w64-x86_64-qt5
git clone https://github.com/shonumi/gbe-plus.git
cd gbe-plus
cmake -S . -B ./build
cmake --build build
# Wait for the install to finish and you can find the full thing as ./build/src/qt/gbe_plus_qt.exe