mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.72k stars 793 forks source link

[3DS] trying to build mgba for 3DS on windows failed #964

Closed roytam1 closed 4 months ago

roytam1 commented 6 years ago

Build Platform: Win7 SP1 x64 devKitPro 1.6.0 devKitPro ARM r47

CMake commandline:

cmake -D3DS=TRUE -G "MSYS Makefiles" -DCMAKE_C_COMPILER=$DEVKITARM/bin/arm-none-eabi-gcc.exe -DCMAKE_CXX_COMPILER=$DEVKITARM/bin/arm-none-eabi-gcc.exe -DCMAKE_ASM_COMPILER=$DEVKITARM/bin/arm-none-eabi-gcc.exe -DCMAKE_AR=$DEVKITARM/bin/arm-none-eabi-ar.exe -DCMAKE_SYSTEM_NAME=Generic

Error:

[ 65%] Building C object CMakeFiles/mgba.dir/src/util/vfs.c.obj
d:/Test/_3DS/mgba/src/util/vfs.c: In function 'VFileOpen':
d:/Test/_3DS/mgba/src/util/vfs.c:67:17: error: 'FS_OPEN_READ' undeclared (first use in this function); did you mean 'FOPEN_MAX'?
  int ctrFlags = FS_OPEN_READ;
                 ^~~~~~~~~~~~
                 FOPEN_MAX
d:/Test/_3DS/mgba/src/util/vfs.c:67:17: note: each undeclared identifier is reported only once for each function it appears in
d:/Test/_3DS/mgba/src/util/vfs.c:70:14: error: 'FS_OPEN_WRITE' undeclared (first use in this function); did you mean 'FS_OPEN_READ'?
   ctrFlags = FS_OPEN_WRITE;
              ^~~~~~~~~~~~~
              FS_OPEN_READ
d:/Test/_3DS/mgba/src/util/vfs.c:81:15: error: 'FS_OPEN_CREATE' undeclared (first use in this function); did you mean 'FS_OPEN_WRITE'?
   ctrFlags |= FS_OPEN_CREATE;
               ^~~~~~~~~~~~~~
               FS_OPEN_WRITE
d:/Test/_3DS/mgba/src/util/vfs.c:83:21: warning: implicit declaration of function 'VFileOpen3DS'; did you mean 'VFileOpenFD'? [-Wimplicit-function-declaration]
  struct VFile* vf = VFileOpen3DS(&sdmcArchive, path, ctrFlags);
                     ^~~~~~~~~~~~
                     VFileOpenFD
d:/Test/_3DS/mgba/src/util/vfs.c:83:35: error: 'sdmcArchive' undeclared (first use in this function)
  struct VFile* vf = VFileOpen3DS(&sdmcArchive, path, ctrFlags);
                                   ^~~~~~~~~~~
make[2]: *** [CMakeFiles/mgba.dir/src/util/vfs.c.obj] Error 1
make[1]: *** [CMakeFiles/mgba.dir/all] Error 2
make: *** [all] Error 2
endrift commented 6 years ago

You should be using the CMakeToolchain.txt file instead of specifying all the paths manually. See this for an example invocation: https://buildbot.mgba.io/api/v2/logs/31208/raw

roytam1 commented 6 years ago

You should be using the CMakeToolchain.txt file instead of specifying all the paths manually.

So I used this to create makefiles:

cmake -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=src/platform/3ds/CMakeToolchain.txt

but where to put citro3d include/lib path? Now I got this:

[ 94%] Building C object 3ds/CMakeFiles/mgba.elf.dir/gui-font.c.obj
In file included from d:/Test/_3DS/mgba/src/platform/3ds/gui-font.c:12:0:
d:/Test/_3DS/mgba/src/platform/3ds/ctr-gpu.h:12:10: fatal error: citro3d.h: No such file or directory
 #include <citro3d.h>
          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [3ds/CMakeFiles/mgba.elf.dir/gui-font.c.obj] Error 1
make[1]: *** [3ds/CMakeFiles/mgba.elf.dir/all] Error 2
make: *** [all] Error 2
roytam1 commented 6 years ago

anyway I hacked around src/platform/3ds/CMakeToolchain.txt for this:

diff --git a/src/platform/3ds/CMakeToolchain.txt b/src/platform/3ds/CMakeToolchain.txt
index 9b67d301..74bfe35b 100644
--- a/src/platform/3ds/CMakeToolchain.txt
+++ b/src/platform/3ds/CMakeToolchain.txt
@@ -24,8 +24,8 @@ endif()
 set(CMAKE_PROGRAM_PATH ${DEVKITARM}/bin)
 set(cross_prefix arm-none-eabi-)
 set(arch_flags "-march=armv6k -mtune=mpcore -mfpu=vfp -mfloat-abi=hard")
-set(inc_flags "-I${CTRULIB}/include ${arch_flags} -mword-relocations")
-set(link_flags "-L${CTRULIB}/lib -lctru -specs=3dsx.specs ${arch_flags}")
+set(inc_flags "-I${CTRULIB}/include -I${DEVKITPRO}/citro3d/include ${arch_flags} -mword-relocations")
+set(link_flags "-L${CTRULIB}/lib -L${DEVKITPRO}/citro3d/lib -lctru -lcitro3d -specs=3dsx.specs ${arch_flags}")

 set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "system name")
 set(CMAKE_SYSTEM_PROCESSOR arm CACHE INTERNAL "processor")
roytam1 commented 6 years ago

OK it builds, but when I tried to load a GBA ROM, it crashes. photo_2018-01-15_19-53-33

endrift commented 4 months ago

Closing due to how stale this undoubtedly is. If it still crashes when built on Windows, please open a new bug.