Building RA_Integration.dll

I have downloaded the source code and built RA_Integration successfully. However using the resulting DLL results in the emulators crashing at startup.

I literally opened VS2015, loaded RA_Integration.sln, built it successfully and replaced the existing DLL of RASnes9x with the resulting DLL so I'm not sure what I did wrong. Unfortunately I have not been able to get any worthy information from the logs.

Interestingly the DLL I built is 1143KB while the DLL that ships with the RA downloads is 1123KB.

You have to build both of them, as of now it would be extremely tedious to change the target (I tried). The current target is Windows XP (last time I checked). Usually if you aren't using the same IDE version which the software was built, it might compile but won't work.

You'd need to upgrade the project to VS2015 with the windows SDK version you choose as the target. VS2015 was built with .NET 4.6, so Windows 10 SDK (stable) would be the optimal choice.

Not sure if anything here helps, but hopefully it'll put you in the right direction.

(dude1286: I haven't got any specific error, the emulators just wouldn't load.)

I run Windows 10.

I have been trying to build snes9x, vba and nes before I found out that I only needed to make a change to RA_Integration but I have not been able to build any of them successfully. Always dependencies issues and I am new to C++ so I didn't know how to fix them (and to be honest I did not want to spend hours on this). The closest I got able to build (I think) is snes9x where I'm left with just one linker error about "zlibdmtx64.lib" but I haven't been able to figure that one.

The only emulator that I am able to build right now out of the box is gens. However I do not see RA_Integration as a dependency in the project. In fact when I download RAGens from the website I do not even see RA_Integration.dll included. Was gens designed differently?

When I start RAGens.exe (the official one), I get an error "LoadLibrary failed: 126: cannot find specified module" followed by "Cannot find or load RA_Integration.dll. Automatically update your RetroAchievements Toolset file?" and if I hit Yes the DLL is downloaded and then it works.

When I start the RAGens.exe that I built, I get the same errors even though the DLL is already there. If I hit Yes it downloads it again but I still get that error and the emulator will not start. I have tried with both the official and my built RA_Integration.dll.

Also I'm not sure to understand what you're saying about the Windows SDK. Is that something I need to download and/or change somewhere in the projects?

Thank you

EDIT: being new here I have no idea how often those emulators are updated ; are the devs (are you one of them?) still active? is there any chance that they stumble upon the issue I linked in my first post and fix it? or is the codebase more or less set in the stone and my only chance to see that bug fixed is to fix it and build it myself? Just curious because I really really would like to see this fixed but I also am not too enclined spending many hours just setting up the environment :/

EDIT2: would it just be simpler to set a VM with the environment that was used to build the current emulators (Windows XP? VS2012?)?

that has done the development for RA, but since he got a big job and started a family, he has not had much time here. I tried to get the overlay to work with OpenGL about two years ago, but had problems with due to having to work with device contexts and having no knowledge of those. There may be somebody with RetroArch who has been changing the code, especially since

EDIT: Forgot to answer the last question. I don't think you would need a VM, but you'd probably need VS 2013 with Windows XP C++ support (it's in the setup). VS 2015 does have Windows XP support but the compilers are vastly different. If can actually fix whatever bug needs fixing, have some people test it and ask whoever is the admin to host it here.

I'm not a developer for RA, I was just trying to debug some of the emus because of constant crashes. I think the culprit is heap corruption but I won't know until I get these damn things to build for Windows 10.

OK, I'll put some screens to clear up some confusion. This is RASnes9x
This was done in Visual 2015 from a untouched repo clone I did awhile back.

This one will show the target platform and VS version used.
Windows XP is the target platform with Visual Studio 12.0 VC++ Compiler and Libraries (2013) being the target's IDE.
To get here right click the start-up project (RASnes9x) and click "Project Properties"

When you do a project upgrade, it'll ask you to retarget the SDK version as well (8.1 or 10), 10 is more compatible.

Project Dependencies
If you want to fix RASnes9x, or it's dependencies yourself, you have to make sure they all work together or it'll result in broken software. It's way to tedious for me however, some stuff like "rapidJson" has been changed and refactoring the current version to work would be way too much work.

To get here right-click the start up project (RASnes9x)->"Build Dependencies"->"Project Dependencies"

It makes sense because the "RA" needs to be "integrated" into Snes9x or else it's just Snes9x w/o RA capabilities.

I have installed Visual Studio 2013 and made sure all the projects were targetting Visual Studio 2013 with Windows XP support.

RA_Integration would not build because of rapidjson missing (I'm not a git user so I don't know if you get the latest version of rapidjson when you clone or what but I simply downloaded the source of RA as a ZIP and the rapidjson folder was empty). So I downloaded an old version of rapidjson (https://github.com/rjeczalik/rapidjson) and put the files where they were expected. With that I was able to build RA_Integration and the other dependencies.

At that point in theory I built RA_Integration with the same tools/compiler that the official build was built with, right?

This time the resulting dll is slightly smaller than the official dll... and still does not work with the official rasnes9x. Not sure if it's because of a wrong version of rapidjson or what.

The RASnes9x will not build because of the following errors which I have absolutely no idea what they mean:

Interestingly I just cleaned/rebuilt and the error #381 as well as the 380 warnings are gone (thanks VS) but I am still left with those 2 errors (which is just one error really I guess).

I'm pretty sure there's a NuGet package for rapidjson but one of the functions was refactored into two different ones.
I couldn't tell you what version it needs because it seems the project doesn't have package.config file.

If you're wondering, NuGet is package manager for Visual Studio and usually used for dnx and .net projects but also work with
c++ as "native".

Yes I have seen that the most recent rapidjson had split filestream.h into filestreamwriter.h and filestreamreader.h, that's why I picked a random old version which had just filestream.h. I know it might not still be the right one to use though but if we cannot know which version is to be used that it not going to be easy...

I don't understand ; are you saying that this null pointer exception is caused by my adding the const keyword? If so what is the correct fix then? How come it doesn't compile as is?

Anyway, building the emulators seems like a lot of work and I only need to make a change in RA_Integration... I really wish I could just rebuild RA_Integration and use it with the already built emulators. I'm sorry I think I asked already but is there really no way to find out a setup that would allow for that? I mean, is it correct that if I build RA_Integration with the same tools Scott (?) originally used, I should not have to rebuild the emulators and I could just replace the RA_Integration.dll? If this is true I would rather focus on that than rebuilding each of the emulators.

EDIT: I just found that there were a link to the rapidjson repo in the RA source repo! So I'm now using that rapidjson. The compiled DLL is 1112k (official is 1123k), still does not work but it should be close.... even though I have no idea what else to change now.

Yeah just rebuild as-is with the same tools Scott used (might need rapidjson) and fix w/e needs fixing with RA_Integration. The best I can say is see which function calls the function that throws an exception. Most of the time there's an uninitialized pointer somewhere. That function expects some kind of input but receives nothing.

Edit: Not really sure what to tell you now, I think there's a guy working on it in the GitHub repo. I think he could tell you the rest.

That is too bad. I am now officially giving up building this thing so I'm also giving up my front-end app which was what I wanted to do in the first place. I'll just cross my fingers that somebody passes by and updates the project to nowadays tools...

So in the same Git shell create a branch for the Beta release - "git checkout tags/v1.0-beta". You'll now be in a Beta branch so the content of your files are correct.

Opening the Project in Visual Studio 2015 (Community Edition)Visual Studio will prompt to upgrade the project files, agree to do so. This simply updated the "ToolsVersion" from "12.0" to "14.0" and the "PlatformToolSet" from "v120_xp" to "v140_xp".

Fixing RA_Integration Compilation ErrorsAt this point, if you try to build RA_Integration (Right-click RA_Integration -> Build) you should get compiler errors due to rapidjson header files not being found.

To add the path to the header files to the RA_Integration project:

â€¢ Right-click "RA_Integration" then navigate to "Properties -> Configuration Properties -> VC++ Directories"
â€¢ Make sure the "Configuration:" dropdown box is set to "All Configurations"
â€¢ Find the "Include Directories" field and add the directory path of the directory that contains the rapidjson directory
â€¢ Note: This is because the path searched for in "RA_Defs.h" is "rapidjson/include/rapidjson/xxx.h"

Fixing RASnes9x Linker ErrorsNow, if you try to build RASnes9x (Build -> Build RASnes9x) you'll get the following linker errors:

The Character Set needs to be changed to "Use Multi-byte Character Set". So right-click RASnes9x -> Properties -> Configuration Properties -> General -> Character Set and choose "Use Multi-Byte Character Set" in the dropdown.

But, you'll get an error that says "One or more values are invalid. Value cannot be null. Parameter name: userSuppliedValue". This is due to the conversion of the project for Visual Studio 2015... The fix is simple, in the same dialog window, enter "8.1" in the "Target Platform Version" field. Then try changing Character Set again and it should work.

And that should do it, the build should be successful now.

Fixing Runtime ErrorsTry to run the debug build (Debug -> Start Debugging). You'll get a warning dialog the first time that says "Cannot load RA_Keys.dll" that is ok just click "Yes".

Fixing Runtime Errors - Debug Assertion Failure (xstring - line 1086)

Summary of Problem and Fix
------------------------------------
You should only see this error if you build outside the Git master branch (in the debug build - asserts are not enabled in the Release build...). This could happen because you copied the source code from a zip file or created a work branch and built in that.

It is set to a valid value in _RA_InitI(). The problem is, back in RA_Init(), _RA_InitI() is not called until after the call that led to g_sClientName being passed to the string library (the "if( nVerInstalled < nLatestDLLVer )" condition) so it is still set to null.

long-Term Solution: I propose simply not calling _RA_SavePreferences() in _RA_Shutdown() if g_sClientName is null and will put a Git pull request together.