NovaSquirrel / Mesen-X

Mesen X is a cross-platform (Windows & Linux) NES/Famicom emulator built in C++ and C#. This fork is meant to gather development efforts from different forks. Deprecated; see https://github.com/SourMesen/Mesen2/
https://www.mesen.ca
GNU General Public License v3.0
161 stars 27 forks source link

[Libretro] Build errors on Windows with Mingw64 #46

Open Ryunam opened 2 years ago

Ryunam commented 2 years ago

Hi, thank you first and foremost for continuing to work on this emulator. I am currently trying to compile a libretro core of the latest code from this repository as well as the one created by @mkwong98, using the makefile contained in the libretro folder with Mingw64 on Windows 10 x64.

Unfortunately, when attempting to build the libretro version in either repo, the compiler throws out several errors and ultimately aborts the process. A few examples of the errors I am getting:

In file included from ../Core/APU.h:7,
                 from ../Core/APU.cpp:2:
../Core/EmulationSettings.h: In member function 'uint32_t EmulationSettings::GetExclusiveRefreshRateByModel(NesModel)':
../Core/EmulationSettings.h:1332:10: warning: enumeration value 'Auto' not handled in switch [-Wswitch]
 1332 |   switch (m) {
      |          ^
In file included from ../Core/EPSMAudio.h:6,
                 from ../Core/BaseMapper.h:13,
                 from ../Core/FDS.h:4,
                 from ../Core/FdsSystemActionManager.h:5,
                 from LibretroKeyManager.h:5,
                 from libretro.cpp:7:
../Core/SSGAudio.h: In member function 'void SSGAudio<channels>::UpdateOutputLevel()':
../Core/SSGAudio.h:29:88: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17'
   29 |   (_console->GetApu()->AddExpansionAudioDelta(channels, _currentOutput - _lastOutput), ...);
      |    
In file included from ../Core/DebuggerTypes.h:3,
                 from ../Core/BaseMapper.h:6,
                 from ../Core/ControlManager.cpp:3:
../Core/EmulationSettings.h: In member function 'uint32_t EmulationSettings::GetExclusiveRefreshRateByModel(NesModel)':
../Core/EmulationSettings.h:1332:10: warning: enumeration value 'Auto' not handled in switch [-Wswitch]
 1332 |   switch (m) {
      |          ^

To the best of my knowledge, most errors seem to be related to either the audio updates that have been implemented recently or something to do with the system model identification, but unfortunately I lack the expertise needed to resolve this issue. Any help or suggestion in this regard will be much appreciated!

For further reference, the same build process works fine by either using SourMesen's original repo, or the libretro version (which is essentially a mirror of Sour's work) found here: https://github.com/libretro/Mesen

mkwong98 commented 2 years ago

Thank you for reporting the errors. I'll try to fix the ones related to my commits. I think adding a default label to the switch statement should fix them.

Ryunam commented 2 years ago

Perfect, thanks a lot! Once these compilation issues are addressed, my plan is to contribute with a few improvements on the libretro side (namely an update to the core options, with sublabel and translation support) and then pull the latest code downstream, so that the libretro mirror is also brought up-to-date. Looking forward to it.

mkwong98 commented 2 years ago

Hi Ryunam. I think I fixed the problems in my commits. The other one in Core/SSGAudio.h is added by @Perkka2 in this commit https://github.com/Perkka2/Mesen/commit/fdee47855aaee9a9e3ac2c95bdadaac82888532c#diff-c46f082694231ba998e7aa27838959b91b0ab758ef5dd75aad1c5aeb1b6ed315 and I don't have enough knowledge to fix it.

Ryunam commented 2 years ago

Thank you for working on this, much appreciated! Which specific repository and/or branch should I check to see your fixes?

mkwong98 commented 2 years ago

The fix is commit: https://github.com/NovaSquirrel/Mesen/commit/eb82a00ebdc318bc910665c5157e81b253effc28 And this commit is already merged into this fork so you can try compiling this fork again.

Perkka2 commented 2 years ago

I intend to take a look at this later this week. I dont know how to test compile though since i’m not getting the issues on my setup.

mkwong98 commented 2 years ago
In file included from ../Core/EPSMAudio.h:6,
                 from ../Core/BaseMapper.h:13,
                 from ../Core/FDS.h:4,
                 from ../Core/FdsSystemActionManager.h:5,
                 from LibretroKeyManager.h:5,
                 from libretro.cpp:7:
../Core/SSGAudio.h: In member function 'void SSGAudio<channels>::UpdateOutputLevel()':
../Core/SSGAudio.h:29:88: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17'
   29 |   (_console->GetApu()->AddExpansionAudioDelta(channels, _currentOutput - _lastOutput), ...);
      |    

This looks like the compiler used does not support fold-expressions. @Ryunam, can you enable this feature on your compiler? Or @Perkka2, can you rewrite that line without using fold-expressions?

Perkka2 commented 2 years ago

@mkwong98 I'm not proficient enough to do that, I got help when initially adding support for the EPSM feels like @Ryunam is using an old compiler and it would be better to upgrade to something newer? or if it's something disabled or outdated in the makefile

Ryunam commented 2 years ago

Unfortunately I don’t think it’s possible to use any different compiler or internal option for this particular case, or at the very least I lack the knowledge that would be needed to explore other options.

The build environment I am using is simply the one suggested in the official documentation for compiling both RetroArch and all Libretro cores on Windows, ie an MSYS2 / Mingw64 installation. See here for further reference:

https://docs.libretro.com/development/retroarch/compilation/windows/

So perhaps we would have to see if something can be changed in the Makefile, but again, I’m not nearly expert enough to meddle in the Makefile code…

mkwong98 commented 2 years ago

@Ryunam Can you try changing line 328 in Libretro/Makefile from CXXFLAGS += -D LIBRETRO $(fpic) -std=c++14 to CXXFLAGS += -D LIBRETRO $(fpic) -std=c++17?

Ryunam commented 2 years ago

Hi, sorry for not responding earlier! Other stuff got in the way and I couldn't resume work on this until now.

Unfortunately, even after applying the change that @mkwong98 suggested, I am getting tons of errors that do not show up when building from the libretro mirror here: https://github.com/libretro/Mesen

The most notable errors that I could spot - or at least, the errors that seem to be entirely absent when building from the libretro repository - are the following:

In file included from ../Core/SoundMixer.h:8,
                 from LibretroSoundManager.h:4,
                 from libretro.cpp:6:
../Core/Snapshotable.h: In instantiation of 'void Snapshotable::InternalStream(ArrayInfo<T>&) [with T = std::array<EPSMAudio::InputEntry, 24>]':
../Core/Snapshotable.h:208:18:   recursively required from 'void Snapshotable::RecursiveStream(T&, T2& ...) [with T = ArrayInfo<short int>; T2 = {ArrayInfo<std::array<EPSMAudio::InputEntry, 24> >, ValueInfo<ym3438_t>, ValueInfo<double>}]'
../Core/Snapshotable.h:208:18:   required from 'void Snapshotable::RecursiveStream(T&, T2& ...) [with T = ArrayInfo<short int>; T2 = {ArrayInfo<short int>, ArrayInfo<std::array<EPSMAudio::InputEntry, 24> >, ValueInfo<ym3438_t>, ValueInfo<double>}]'
../Core/Snapshotable.h:225:18:   required from 'void Snapshotable::Stream(T& ...) [with T = {ArrayInfo<short int>, ArrayInfo<short int>, ArrayInfo<std::array<EPSMAudio::InputEntry, 24> >, ValueInfo<ym3438_t>, ValueInfo<double>}]'
../Core/EPSMAudio.h:174:63:   required from here
../Core/Snapshotable.h:150:10: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct std::array<EPSMAudio::InputEntry, 24>'; use assignment or value-initialization instead [-Wclass-memaccess]
  150 |    memset(info.Array, 0, sizeof(T) * info.ElementCount);
      |    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from P:/MSYS2/mingw64/include/c++/10.3.0/tuple:39,
                 from P:/MSYS2/mingw64/include/c++/10.3.0/functional:54,
                 from P:/MSYS2/mingw64/include/c++/10.3.0/pstl/glue_algorithm_defs.h:13,
                 from P:/MSYS2/mingw64/include/c++/10.3.0/algorithm:74,
                 from libretro.cpp:4:
P:/MSYS2/mingw64/include/c++/10.3.0/array:94:12: note: 'struct std::array<EPSMAudio::InputEntry, 24>' declared here
   94 |     struct array
      |            ^~~~~
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text+0x92f): undefined reference to `PSG_writeReg'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text+0xcb8): undefined reference to `PSG_writeReg'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text+0xc861): undefined reference to `PSG_new'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text+0xc892): undefined reference to `PSG_reset'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text+0xc910): undefined reference to `OPN2_Reset'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text+0xc917): undefined reference to `OPN2_SetChipType'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text$_ZN8SSGAudioIJL12AudioChannel11ELS0_12EEE10ClockAudioEv[_ZN8SSGAudioIJL12AudioChannel11ELS0_12EEE10ClockAudioEv]+0x8c): undefined reference to `PSG_calc'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text$_ZN9EPSMAudio10ClockAudioEv[_ZN9EPSMAudio10ClockAudioEv]+0x274): undefined reference to `OPN2_Clock'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text$_ZN9EPSMAudio10ClockAudioEv[_ZN9EPSMAudio10ClockAudioEv]+0x2d6): undefined reference to `OPN2_Write'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.text$_ZN9EPSMAudio10ClockAudioEv[_ZN9EPSMAudio10ClockAudioEv]+0x3eb): undefined reference to `PSG_calc'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/BaseMapper.o:BaseMapper.cpp:(.rdata$.refptr.PSG_delete[.refptr.PSG_delete]+0x0): undefined reference to `PSG_delete'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN9Vrc7Audio10ClockAudioEv[_ZN9Vrc7Audio10ClockAudioEv]+0xc4): undefined reference to `OPLL_Clock(opll_t*, int*)'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN9Vrc7Audio10ClockAudioEv[_ZN9Vrc7Audio10ClockAudioEv]+0xf2): undefined reference to `OPLL_Write(opll_t*, unsigned int, unsigned char)'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN11SunsoftFme713WriteRegisterEth[_ZN11SunsoftFme713WriteRegisterEth]+0x68): undefined reference to `PSG_writeReg'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN8SSGAudioIJL12AudioChannel10EEE10ClockAudioEv[_ZN8SSGAudioIJL12AudioChannel10EEE10ClockAudioEv]+0xc4): undefined reference to `PSG_calc'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN11SunsoftFme710InitMapperEv[_ZN11SunsoftFme710InitMapperEv]+0x84): undefined reference to `PSG_new'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN11SunsoftFme710InitMapperEv[_ZN11SunsoftFme710InitMapperEv]+0xaf): undefined reference to `PSG_reset'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/MapperFactory.o:MapperFactory.cpp:(.text$_ZN4VRC710InitMapperEv[_ZN4VRC710InitMapperEv]+0xdb): undefined reference to `OPLL_Reset(opll_t*, unsigned int)'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x273d): undefined reference to `OPLL_Reset(opll_t*, unsigned int)'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x2ad9): undefined reference to `PSG_new'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x2b0a): undefined reference to `PSG_reset'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x2bb2): undefined reference to `PSG_new'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x2bdc): undefined reference to `PSG_reset'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x2c56): undefined reference to `OPN2_Reset'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x2c5d): undefined reference to `OPN2_SetChipType'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text+0x111d): undefined reference to `PSG_writeReg'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text$_ZN9EPSMAudio13WriteRegisterEthhhh[_ZN9EPSMAudio13WriteRegisterEthhhh]+0x2b0): undefined reference to `PSG_writeReg'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text$_ZN9EPSMAudio13WriteRegisterEthhhh[_ZN9EPSMAudio13WriteRegisterEthhhh]+0x459): undefined reference to `PSG_writeReg'
P:/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../Core/NsfMapper.o:NsfMapper.cpp:(.text$_ZN9EPSMAudio13WriteRegisterEthhhh[_ZN9EPSMAudio13WriteRegisterEthhhh]+0x87e): undefined reference to `PSG_writeReg'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:340: mesen_libretro.dll] Error 1

A lot of these problems seem to be related to the Core/Snapshotable.h file, but there's also a big amount of "undefined references" at the end.

mkwong98 commented 2 years ago

I think line 171 in EPSMAudio.h is not correctly handling _inputBuffer. ArrayInfo is for array and not for std:array. Maybe change it to ArrayInfo<InputBuffer> inputBuffer{ _inputBuffer.data(), INPUT_BUFFER_SIZE };

Perkka2 commented 2 years ago

I think line 171 in EPSMAudio.h is not correctly handling _inputBuffer. ArrayInfo is for array and not for std:array. Maybe change it to ArrayInfo<InputBuffer> inputBuffer{ _inputBuffer.data(), INPUT_BUFFER_SIZE };

Error (active) | E0144 | a value of type "EPSMAudio::InputEntry *" cannot be used to initialize an entity of type "EPSMAudio::InputBuffer *" Sorry no go with that

mkwong98 commented 2 years ago

Error (active) | E0144 | a value of type "EPSMAudio::InputEntry *" cannot be used to initialize an entity of type "EPSMAudio::InputBuffer *" Sorry no go with that

How about this? ArrayInfo<InputEntry> inputBuffer{ _inputBuffer.data(), INPUT_BUFFER_SIZE }; Sorry, I'm not replying from my home computer so I can't test it and I'm not too familiar with templates and other newer C++ features.

I think the cause of the error is that ArrayInfo is expecting an array and not a std::array. Passing a pointer to a std::array means it is being treated as an object inside an array. When Snapshotable.h uses memset on each item in the array, the compiler finds a std::array and it gives this warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct std::array<EPSMAudio::InputEntry, 24>'; use assignment or value-initialization instead [-Wclass-memaccess]

I guess VS does not stop on this warning and Mingw64 does and I think this warning needs to be fixed.

Perkka2 commented 2 years ago

Ok it works well on windows atleast, though the original solution did too without any warnings.

added a pull request with this update

SupervisedThinking commented 2 years ago

https://github.com/NovaSquirrel/Mesen-X/releases/tag/1.0.0 fails to build on Linux with:

/mnt/dev/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ -fPIC -pthread -shared -Wl,--version-script=./link.T -Wl,--no-undefined  -omesen_libretro.so ../SevenZip/7zAlloc.o ../SevenZip/7zArcIn.o ../SevenZip/7zBuf.o ../SevenZip/7zCrc.o ../SevenZip/7zCrcOpt.o ../SevenZip/7zDec.o ../SevenZip/7zFile.o ../SevenZip/7zMemBuffer.o ../SevenZip/7zStream.o ../SevenZip/Bcj2.o ../SevenZip/Bra.o ../SevenZip/Bra86.o ../SevenZip/BraIA64.o ../SevenZip/CpuArch.o ../SevenZip/Delta.o ../SevenZip/Lzma2Dec.o ../SevenZip/LzmaDec.o ../SevenZip/Ppmd7.o ../SevenZip/Ppmd7Dec.o ../SevenZip/Precomp.o ./libretro.o ../Core/APU.o ../Core/Assembler.o ../Core/AutomaticRomTest.o ../Core/AutoSaveManager.o ../Core/BaseControlDevice.o ../Core/BaseExpansionAudio.o ../Core/BaseMapper.o ../Core/BaseRenderer.o ../Core/BaseVideoFilter.o ../Core/BatteryManager.o ../Core/BisqwitNtscFilter.o ../Core/BizhawkMovie.o ../Core/Breakpoint.o ../Core/CheatManager.o ../Core/CodeDataLogger.o ../Core/CodeRunner.o ../Core/Console.o ../Core/ControlManager.o ../Core/CPU.o ../Core/CrossFeedFilter.o ../Core/Debugger.o ../Core/DebugHud.o ../Core/DefaultVideoFilter.o ../Core/RawVideoFilter.o ../Core/DeltaModulationChannel.o ../Core/Disassembler.o ../Core/DisassemblyInfo.o ../Core/EmulationSettings.o ../Core/EventManager.o ../Core/ExpressionEvaluator.o ../Core/FceuxMovie.o ../Core/FDS.o ../Core/FdsLoader.o ../Core/GameClient.o ../Core/GameClientConnection.o ../Core/GameConnection.o ../Core/GameDatabase.o ../Core/GameServer.o ../Core/GameServerConnection.o ../Core/HdAudioDevice.o ../Core/HdNesPack.o ../Core/HdPackBuilder.o ../Core/HdPackLoader.o ../Core/HdPpu.o ../Core/HdVideoFilter.o ../Core/HistoryViewer.o ../Core/iNesLoader.o ../Core/KeyManager.o ../Core/LabelManager.o ../Core/MapperFactory.o ../Core/MemoryAccessCounter.o ../Core/MemoryDumper.o ../Core/MemoryManager.o ../Core/MesenMovie.o ../Core/MessageManager.o ../Core/MovieManager.o ../Core/MovieRecorder.o ../Core/NESHeader.o ../Core/NotificationManager.o ../Core/NsfLoader.o ../Core/NsfMapper.o ../Core/NsfPpu.o ../Core/NtscFilter.o ../Core/OggMixer.o ../Core/OggReader.o ../Core/PPU.o ../Core/PerformanceTracker.o ../Core/PgoUtilities.o ../Core/Profiler.o ../Core/RecordedRomTest.o ../Core/ReverbFilter.o ../Core/RewindData.o ../Core/RewindManager.o ../Core/RomLoader.o ../Core/RotateFilter.o ../Core/SaveStateManager.o ../Core/ScaleFilter.o ../Core/ScriptHost.o ../Core/ScriptingContext.o ../Core/ShortcutKeyHandler.o ../Core/Snapshotable.o ../Core/SoundMixer.o ../Core/stdafx.o ../Core/StereoCombFilter.o ../Core/StereoDelayFilter.o ../Core/StereoPanningFilter.o ../Core/StudyBoxLoader.o ../Core/TraceLogger.o ../Core/UnifLoader.o ../Core/VideoDecoder.o ../Core/VideoHud.o ../Core/VideoRenderer.o ../Core/VirtualFile.o ../Core/VsControlManager.o ../Core/WaveRecorder.o ../Utilities/ArchiveReader.o ../Utilities/AutoResetEvent.o ../Utilities/AviRecorder.o ../Utilities/AviWriter.o ../Utilities/blip_buf.o ../Utilities/BpsPatcher.o ../Utilities/CamstudioCodec.o ../Utilities/CRC32.o ../Utilities/FolderUtilities.o ../Utilities/GifRecorder.o ../Utilities/HexUtilities.o ../Utilities/IpsPatcher.o ../Utilities/md5.o ../Utilities/miniz.o ../Utilities/nes_ntsc.o ../Utilities/PlatformUtilities.o ../Utilities/PNGHelper.o ../Utilities/sha1.o ../Utilities/SimpleLock.o ../Utilities/Socket.o ../Utilities/stb_vorbis.o ../Utilities/stdafx.o ../Utilities/SZReader.o ../Utilities/Timer.o ../Utilities/UpsPatcher.o ../Utilities/UTF8Util.o ../Utilities/WavReader.o ../Utilities/ZipReader.o ../Utilities/ZipWriter.o ../Utilities/ZmbvCodec.o ../Utilities/HQX/hq2x.o ../Utilities/HQX/hq3x.o ../Utilities/HQX/hq4x.o ../Utilities/HQX/init.o ../Utilities/KreedSaiEagle/2xSai.o ../Utilities/KreedSaiEagle/Super2xSai.o ../Utilities/KreedSaiEagle/SuperEagle.o ../Utilities/Scale2x/scale2x.o ../Utilities/Scale2x/scale3x.o ../Utilities/Scale2x/scalebit.o ../Utilities/xBRZ/xbrz.o -march=x86-64 -m64 -Wl,--as-needed -fuse-ld=gold -lm
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::WriteEPSM(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::WriteEPSM(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'PSG_new'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'PSG_delete'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'PSG_reset'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'OPN2_Reset'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'OPN2_SetChipType'
../Core/BaseMapper.o:BaseMapper.cpp:function SSGAudio<(AudioChannel)11, (AudioChannel)12>::ClockAudio(): error: undefined reference to 'PSG_calc'
../Core/BaseMapper.o:BaseMapper.cpp:function EPSMAudio::ClockAudio(): error: undefined reference to 'OPN2_Clock'
../Core/BaseMapper.o:BaseMapper.cpp:function EPSMAudio::ClockAudio(): error: undefined reference to 'OPN2_Write'
../Core/BaseMapper.o:BaseMapper.cpp:function EPSMAudio::ClockAudio(): error: undefined reference to 'PSG_calc'
../Core/MapperFactory.o:MapperFactory.cpp:function Vrc7Audio::ClockAudio(): error: undefined reference to 'OPLL_Clock(opll_t*, int*)'
../Core/MapperFactory.o:MapperFactory.cpp:function Vrc7Audio::ClockAudio(): error: undefined reference to 'OPLL_Write(opll_t*, unsigned int, unsigned char)'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::WriteRegister(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
../Core/MapperFactory.o:MapperFactory.cpp:function SSGAudio<(AudioChannel)10>::ClockAudio(): error: undefined reference to 'PSG_calc'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::InitMapper(): error: undefined reference to 'PSG_new'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::InitMapper(): error: undefined reference to 'PSG_delete'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::InitMapper(): error: undefined reference to 'PSG_reset'
../Core/MapperFactory.o:MapperFactory.cpp:function VRC7::InitMapper(): error: undefined reference to 'OPLL_Reset(opll_t*, unsigned int)'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'OPLL_Reset(opll_t*, unsigned int)'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_new'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_delete'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_reset'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_new'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_reset'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'OPN2_Reset'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'OPN2_SetChipType'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::WriteRegister(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
collect2: error: ld returned 1 exit status
make: *** [Makefile:340: mesen_libretro.so] Error 1
make: Leaving directory '/mnt/dev/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/mesen-1.0.0/Libretro'
FAILURE: scripts/build mesen during make_target (default)
Perkka2 commented 2 years ago

https://github.com/NovaSquirrel/Mesen-X/releases/tag/1.0.0 fails to build on Linux with:

/mnt/dev/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ -fPIC -pthread -shared -Wl,--version-script=./link.T -Wl,--no-undefined  -omesen_libretro.so ../SevenZip/7zAlloc.o ../SevenZip/7zArcIn.o ../SevenZip/7zBuf.o ../SevenZip/7zCrc.o ../SevenZip/7zCrcOpt.o ../SevenZip/7zDec.o ../SevenZip/7zFile.o ../SevenZip/7zMemBuffer.o ../SevenZip/7zStream.o ../SevenZip/Bcj2.o ../SevenZip/Bra.o ../SevenZip/Bra86.o ../SevenZip/BraIA64.o ../SevenZip/CpuArch.o ../SevenZip/Delta.o ../SevenZip/Lzma2Dec.o ../SevenZip/LzmaDec.o ../SevenZip/Ppmd7.o ../SevenZip/Ppmd7Dec.o ../SevenZip/Precomp.o ./libretro.o ../Core/APU.o ../Core/Assembler.o ../Core/AutomaticRomTest.o ../Core/AutoSaveManager.o ../Core/BaseControlDevice.o ../Core/BaseExpansionAudio.o ../Core/BaseMapper.o ../Core/BaseRenderer.o ../Core/BaseVideoFilter.o ../Core/BatteryManager.o ../Core/BisqwitNtscFilter.o ../Core/BizhawkMovie.o ../Core/Breakpoint.o ../Core/CheatManager.o ../Core/CodeDataLogger.o ../Core/CodeRunner.o ../Core/Console.o ../Core/ControlManager.o ../Core/CPU.o ../Core/CrossFeedFilter.o ../Core/Debugger.o ../Core/DebugHud.o ../Core/DefaultVideoFilter.o ../Core/RawVideoFilter.o ../Core/DeltaModulationChannel.o ../Core/Disassembler.o ../Core/DisassemblyInfo.o ../Core/EmulationSettings.o ../Core/EventManager.o ../Core/ExpressionEvaluator.o ../Core/FceuxMovie.o ../Core/FDS.o ../Core/FdsLoader.o ../Core/GameClient.o ../Core/GameClientConnection.o ../Core/GameConnection.o ../Core/GameDatabase.o ../Core/GameServer.o ../Core/GameServerConnection.o ../Core/HdAudioDevice.o ../Core/HdNesPack.o ../Core/HdPackBuilder.o ../Core/HdPackLoader.o ../Core/HdPpu.o ../Core/HdVideoFilter.o ../Core/HistoryViewer.o ../Core/iNesLoader.o ../Core/KeyManager.o ../Core/LabelManager.o ../Core/MapperFactory.o ../Core/MemoryAccessCounter.o ../Core/MemoryDumper.o ../Core/MemoryManager.o ../Core/MesenMovie.o ../Core/MessageManager.o ../Core/MovieManager.o ../Core/MovieRecorder.o ../Core/NESHeader.o ../Core/NotificationManager.o ../Core/NsfLoader.o ../Core/NsfMapper.o ../Core/NsfPpu.o ../Core/NtscFilter.o ../Core/OggMixer.o ../Core/OggReader.o ../Core/PPU.o ../Core/PerformanceTracker.o ../Core/PgoUtilities.o ../Core/Profiler.o ../Core/RecordedRomTest.o ../Core/ReverbFilter.o ../Core/RewindData.o ../Core/RewindManager.o ../Core/RomLoader.o ../Core/RotateFilter.o ../Core/SaveStateManager.o ../Core/ScaleFilter.o ../Core/ScriptHost.o ../Core/ScriptingContext.o ../Core/ShortcutKeyHandler.o ../Core/Snapshotable.o ../Core/SoundMixer.o ../Core/stdafx.o ../Core/StereoCombFilter.o ../Core/StereoDelayFilter.o ../Core/StereoPanningFilter.o ../Core/StudyBoxLoader.o ../Core/TraceLogger.o ../Core/UnifLoader.o ../Core/VideoDecoder.o ../Core/VideoHud.o ../Core/VideoRenderer.o ../Core/VirtualFile.o ../Core/VsControlManager.o ../Core/WaveRecorder.o ../Utilities/ArchiveReader.o ../Utilities/AutoResetEvent.o ../Utilities/AviRecorder.o ../Utilities/AviWriter.o ../Utilities/blip_buf.o ../Utilities/BpsPatcher.o ../Utilities/CamstudioCodec.o ../Utilities/CRC32.o ../Utilities/FolderUtilities.o ../Utilities/GifRecorder.o ../Utilities/HexUtilities.o ../Utilities/IpsPatcher.o ../Utilities/md5.o ../Utilities/miniz.o ../Utilities/nes_ntsc.o ../Utilities/PlatformUtilities.o ../Utilities/PNGHelper.o ../Utilities/sha1.o ../Utilities/SimpleLock.o ../Utilities/Socket.o ../Utilities/stb_vorbis.o ../Utilities/stdafx.o ../Utilities/SZReader.o ../Utilities/Timer.o ../Utilities/UpsPatcher.o ../Utilities/UTF8Util.o ../Utilities/WavReader.o ../Utilities/ZipReader.o ../Utilities/ZipWriter.o ../Utilities/ZmbvCodec.o ../Utilities/HQX/hq2x.o ../Utilities/HQX/hq3x.o ../Utilities/HQX/hq4x.o ../Utilities/HQX/init.o ../Utilities/KreedSaiEagle/2xSai.o ../Utilities/KreedSaiEagle/Super2xSai.o ../Utilities/KreedSaiEagle/SuperEagle.o ../Utilities/Scale2x/scale2x.o ../Utilities/Scale2x/scale3x.o ../Utilities/Scale2x/scalebit.o ../Utilities/xBRZ/xbrz.o -march=x86-64 -m64 -Wl,--as-needed -fuse-ld=gold -lm
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::WriteEPSM(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::WriteEPSM(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'PSG_new'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'PSG_delete'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'PSG_reset'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'OPN2_Reset'
../Core/BaseMapper.o:BaseMapper.cpp:function BaseMapper::Initialize(RomData&): error: undefined reference to 'OPN2_SetChipType'
../Core/BaseMapper.o:BaseMapper.cpp:function SSGAudio<(AudioChannel)11, (AudioChannel)12>::ClockAudio(): error: undefined reference to 'PSG_calc'
../Core/BaseMapper.o:BaseMapper.cpp:function EPSMAudio::ClockAudio(): error: undefined reference to 'OPN2_Clock'
../Core/BaseMapper.o:BaseMapper.cpp:function EPSMAudio::ClockAudio(): error: undefined reference to 'OPN2_Write'
../Core/BaseMapper.o:BaseMapper.cpp:function EPSMAudio::ClockAudio(): error: undefined reference to 'PSG_calc'
../Core/MapperFactory.o:MapperFactory.cpp:function Vrc7Audio::ClockAudio(): error: undefined reference to 'OPLL_Clock(opll_t*, int*)'
../Core/MapperFactory.o:MapperFactory.cpp:function Vrc7Audio::ClockAudio(): error: undefined reference to 'OPLL_Write(opll_t*, unsigned int, unsigned char)'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::WriteRegister(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
../Core/MapperFactory.o:MapperFactory.cpp:function SSGAudio<(AudioChannel)10>::ClockAudio(): error: undefined reference to 'PSG_calc'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::InitMapper(): error: undefined reference to 'PSG_new'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::InitMapper(): error: undefined reference to 'PSG_delete'
../Core/MapperFactory.o:MapperFactory.cpp:function SunsoftFme7::InitMapper(): error: undefined reference to 'PSG_reset'
../Core/MapperFactory.o:MapperFactory.cpp:function VRC7::InitMapper(): error: undefined reference to 'OPLL_Reset(opll_t*, unsigned int)'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'OPLL_Reset(opll_t*, unsigned int)'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_new'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_delete'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_reset'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_new'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'PSG_reset'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'OPN2_Reset'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::InitMapper(): error: undefined reference to 'OPN2_SetChipType'
../Core/NsfMapper.o:NsfMapper.cpp:function NsfMapper::WriteRegister(unsigned short, unsigned char): error: undefined reference to 'PSG_writeReg'
collect2: error: ld returned 1 exit status
make: *** [Makefile:340: mesen_libretro.so] Error 1
make: Leaving directory '/mnt/dev/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/mesen-1.0.0/Libretro'
FAILURE: scripts/build mesen during make_target (default)

This seems rather unrelated to the specific build error. It feels like it's not including the EPSMAudio.h file or something

But you're building libretro and not mesen itself i persume

SupervisedThinking commented 2 years ago

@Perkka2 well it looks like the same undefined reference to 'PSG_writeReg' as in https://github.com/NovaSquirrel/Mesen-X/issues/46#issuecomment-945209770 & it's indeed the libretro core

Perkka2 commented 2 years ago

I have no idea of how to correctly setup Mingw64 to build this, have tried a bit but cant really get it to even do a decent try. I've created an Ubuntu 18.04 VM and were able to build libretro without issues. and building mesen from visual studio also works well.

I dont know what more to do currently.

SupervisedThinking commented 2 years ago

I've opened a new issue https://github.com/NovaSquirrel/Mesen-X/issues/62

mkwong98 commented 2 years ago

I have Mingw64 working on my PC. There is another error with InputEntry. Initialization within the struct definition makes the struct non-trivial which still causes problems with memset. Remove those will fix that problem. And the undefined reference errors is caused by new cpp files not added to Makefile.common. Those are emu2149.cpp, ym3438.cpp and opll.cpp. I'll post a pull request to fix those.

Perkka2 commented 2 years ago

@mkwong98 Awesome!

negativeExponent commented 1 year ago

the best option here is either to wait for official mingw64 to release updated gcc or just switch over to an environment that supports latest gcc, like Arch.

im on Arch so cross-compiling is not an issue. BUT i had to use this on github CI to build a windows target that required std=c++17:

https://github.com/negativeExponent/libretro_builds/blob/main/.github/workflows/win64_mesen_msys2.yml

btw, this is a duplicate of https://github.com/NovaSquirrel/Mesen-X/issues/95