Win building desmume core odyssey
#1
I spent some time trying to get the desmume core build for retroplayer and thought i'd share my experiences so far.

At first i used the existing game.libretro.desmume github to add the core to the kodi-addons using the cmake logic. I soon discovered some weird type mismatch errors which i could resolve by not using the mingw provided in the kodi msys download, but some more recent version from the mingw64 project.

Unfortunately more and more compile errors appeared and so after some bugfixing i decided it would be better to use a more recent version of the desmume core. The current desmume in kodi-games uses the year old abandoned desmume-libretro github which is a simple wrapper and not the svn-based desmume github which is much more up to date.

So after all that cloning, forking, pushing and pulling that was then necessary to get it into the kodi buildsystem i managed to start compiling it finally ... only to get the next errors.

Talking with some guys in #retroarch i found out that their win32 build was not working for some time too and they get the same error:

Code:
g++ -DHAVE_JIT -DNDEBUG -O3 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/libfat/cache.o src/utils/libfat/cache.cpp
g++ -DHAVE_JIT -DNDEBUG -O3 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/libfat/directory.o src/utils/libfat/directory.cpp
g++ -DHAVE_JIT -DNDEBUG -O3 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/libfat/disc.o src/utils/libfat/disc.cpp
src/utils/task.cpp: In member function 'void Task::Impl::start(bool)':
src/utils/task.cpp:145:75: error: invalid conversion from 'DWORD (__attribute__((__stdcall__)) *)(void*) {aka long unsigned int (__attribute__((__stdcall__)) *)(void*)}' to 'LPTHREAD_START_ROUTINE {aka long unsigned int (*)(void*)}' [-fpermissive]
  hThread = CreateThread(NULL,0,Task::Impl::s_taskProc,(void*)this, 0, NULL);
                                                                           ^
In file included from C:/Toolchains/msys64/mingw32/i686-w64-mingw32/include/winbase.h:29:0,
                 from C:/Toolchains/msys64/mingw32/i686-w64-mingw32/include/windows.h:70,
                 from src/utils/task.cpp:26:
C:/Toolchains/msys64/mingw32/i686-w64-mingw32/include/processthreadsapi.h:84:28: note: initializing argument 3 of 'void* CreateThread(LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD)'
   WINBASEAPI HANDLE WINAPI CreateThread (LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
                            ^
g++ -DHAVE_JIT -DNDEBUG -O3 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/libfat/fatdir.o src/utils/libfat/fatdir.cpp
<builtin>: recipe for target 'src/utils/task.o' failed
make: *** [src/utils/task.o] Error 1
make: *** Waiting for unfinished jobs....

But as they are able to build for win64 they not yet bothered with it and say its some kinf of mingw bug. Unfortunately i cant use the 64bit dll in retroplayer because the wrapper in kodi which loads the cores complaines about the dll not being win32 Smile

So i head over to #mingw-w64 and asked for assistance and the guys there were kindly pointing out that the calling convention is wrong. So after removing __stdcall from the thread worker function in the error above i managed to compile the corresponing file. Unfortunately it not yet links as it now throws some undefined symbols (http://hastebin.com/ayarehuhal.tex):

Code:
3>    g++ -DHAVE_JIT -g -O0 -m32 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/AsmJit/x86/x86func.o src/utils/AsmJit/x86/x86func.cpp
3>    g++ -DHAVE_JIT -g -O0 -m32 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/AsmJit/x86/x86operand.o src/utils/AsmJit/x86/x86operand.cpp
3>    g++ -DHAVE_JIT -g -O0 -m32 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/AsmJit/x86/x86util.o src/utils/AsmJit/x86/x86util.cpp
3>    g++ -DHAVE_JIT -g -O0 -m32 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/libretro/dirent_win32/dirent.o src/libretro/dirent_win32/dirent.c
3>    g++ -DHAVE_JIT -g -O0 -m32 -D__LIBRETRO__  -iquote src/libretro/dirent_win32 -iquote src/windows -iquote src -iquote src/libretro    -c -o src/utils/ConvertUTF.o src/utils/ConvertUTF.c
3>    g++   -m32 -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=src/libretro/link.T -o desmume_libretro.dll src/armcpu.o src/arm_instructions.o src/bios.o src/cp15.o src/common.o src/debug.o src/Disassembler.o src/emufile.o src/encrypt.o src/FIFO.o src/firmware.o src/GPU.o src/mc.o src/path.o src/readwrite.o src/wifi.o src/MMU.o src/NDSSystem.o src/ROMReader.o src/render3D.o src/rtc.o src/saves.o src/slot1.o src/slot2.o src/SPU.o src/matrix.o src/gfx3d.o src/thumb_instructions.o src/movie.o src/utils/advanscene.o src/utils/datetime.o src/utils/guid.o src/utils/emufat.o src/utils/fsnitro.o src/utils/md5.o src/utils/xstring.o src/utils/decrypt/crc.o src/utils/decrypt/decrypt.o src/utils/decrypt/header.o src/utils/task.o src/utils/vfat.o src/utils/dlditool.o src/utils/libfat/cache.o src/utils/libfat/directory.o src/utils/libfat/disc.o src/utils/libfat/fatdir.o src/utils/libfat/fatfile.o src/utils/libfat/filetime.o src/utils/libfat/file_allocation_table.o src/utils/libfat/libfat.o src/utils/libfat/libfat_public_api.o src/utils/libfat/lock.o src/utils/libfat/partition.o src/utils/tinyxml/tinystr.o src/utils/tinyxml/tinyxml.o src/utils/tinyxml/tinyxmlerror.o src/utils/tinyxml/tinyxmlparser.o src/addons/slot2_auto.o src/addons/slot2_mpcf.o src/addons/slot2_paddle.o src/addons/slot2_gbagame.o src/addons/slot2_none.o src/addons/slot2_rumblepak.o src/addons/slot2_guitarGrip.o src/addons/slot2_expMemory.o src/addons/slot2_piano.o src/addons/slot2_passme.o src/addons/slot1_none.o src/addons/slot1_r4.o src/addons/slot1comp_mc.o src/addons/slot1comp_rom.o src/addons/slot1comp_protocol.o src/addons/slot1_retail_mcrom.o src/addons/slot1_retail_mcrom_debug.o src/addons/slot1_retail_nand.o src/addons/slot1_retail_auto.o src/cheatSystem.o src/texcache.o src/rasterize.o src/metaspu/metaspu.o src/version.o src/mic.o src/GPU_osd_stub.o src/driver.o src/fs-linux.o src/libretro/libretro.o src/libretro/scrc32.o src/arm_jit.o src/utils/AsmJit/core/assembler.o src/utils/AsmJit/core/assert.o src/utils/AsmJit/core/buffer.o src/utils/AsmJit/core/compiler.o src/utils/AsmJit/core/compilercontext.o src/utils/AsmJit/core/compilerfunc.o src/utils/AsmJit/core/compileritem.o src/utils/AsmJit/core/context.o src/utils/AsmJit/core/cpuinfo.o src/utils/AsmJit/core/defs.o src/utils/AsmJit/core/func.o src/utils/AsmJit/core/logger.o src/utils/AsmJit/core/memorymanager.o src/utils/AsmJit/core/memorymarker.o src/utils/AsmJit/core/operand.o src/utils/AsmJit/core/stringbuilder.o src/utils/AsmJit/core/stringutil.o src/utils/AsmJit/core/virtualmemory.o src/utils/AsmJit/core/zonememory.o src/utils/AsmJit/x86/x86assembler.o src/utils/AsmJit/x86/x86compiler.o src/utils/AsmJit/x86/x86compilercontext.o src/utils/AsmJit/x86/x86compilerfunc.o src/utils/AsmJit/x86/x86compileritem.o src/utils/AsmJit/x86/x86cpuinfo.o src/utils/AsmJit/x86/x86defs.o src/utils/AsmJit/x86/x86func.o src/utils/AsmJit/x86/x86operand.o src/utils/AsmJit/x86/x86util.o src/libretro/dirent_win32/dirent.o src/utils/ConvertUTF.o
3>CUSTOMBUILD : warning : resolving __imp__GetSystemInfo by linking to __imp__GetSystemInfo@4 [D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume.vcxproj]
3>    Use --enable-stdcall-fixup to disable these warnings
3>    Use --disable-stdcall-fixup to disable these fixups
3>CUSTOMBUILD : warning : resolving __imp__Sleep by linking to __imp__Sleep@4 [D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume.vcxproj]
3>    src/utils/task.o: In function `ZN4Task4Impl8taskProcEv':
3>    D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume\src\desmume/src/utils/task.cpp:125: undefined reference to `_imp__WaitForSingleObject'
3>    D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume\src\desmume/src/utils/task.cpp:132: undefined reference to `_imp__SetEvent'
3>    src/utils/task.o: In function `ZN4Task4Impl5startEb':
3>    D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume\src\desmume/src/utils/task.cpp:143: undefined reference to `_imp__CreateEventA'
3>    D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume\src\desmume/src/utils/task.cpp:144: undefined reference to `_imp__CreateEventA'
3>    D:\Dev\xbmc_dev\retroplayer\project\cmake\addons\build\game.libretro.desmume-prefix\src\game.libretro.desmume-build\desmume\src\desmume/src/utils/task.cpp:145: undefined reference to `_imp__CreateThread'

So thats were i stand now after trying the last days with multiple compilers, calling conventions, linker and compiler flags and dozen of rewrites and debugging attempts. My motivation is kind of low now to go on with this stuff - i think every developer out there knows the feeling Smile

Oh and btw. i could compile above code without any hassles on win64 on the first try and with every compiler (http://hastebin.com/uzuzigibih.tex), only win32 is giving me the headaches.

So thanks for listening and sorry for the lengthy post Smile
Reply

Logout Mark Read Team Forum Stats Members Help
building desmume core odyssey0