Forgot password?
login to RetroAchievements:

Building RA_Integration.dll

Page: 1 2 3 >

Posted: 13 Jul, 2016 20:06
Last Edit: 13 Jul, 2016 20:06

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.

I would like to be able to build RA_Integration successfully in order to then test a quick change in hopes to help fixing this issue.

Anybody willing to help?


Posted: 14 Jul, 2016 01:30
Which version of Windows do you have?

RA_Integration is a project dependency of all the RA emulators.

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.

Posted: 14 Jul, 2016 03:37
Last Edit: 14 Jul, 2016 03:38
Let me know what you find, I've been trying to fix a bug about adding game titles in that have strange characters at the beginning of the title. Can mess up adding new titles for later users.

Were you getting an error about an invalid null pointer at line 1097 of xstring?

Posted: 14 Jul, 2016 09:47
Last Edit: 14 Jul, 2016 09:56
(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?)?

Posted: 14 Jul, 2016 14:07
It has been mostly 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 didn't develop in VS 2015.

Posted: 15 Jul, 2016 01:55
Last Edit: 15 Jul, 2016 02:27
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.

Posted: 15 Jul, 2016 23:37
Thanks for the details. I will try but I do not have too much hope :( Sounds like this project is basically dead because outdated which is unfortunate.

Posted: 16 Jul, 2016 00:55
Last Edit: 16 Jul, 2016 00:57
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 ( 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).

Any idea what that means?

Posted: 16 Jul, 2016 01:07
I have also tried fceux. I had to actually change the code in order to compile (added "const", see below) but at least got it to compile!

But... it crashes upon startup with the following, which looks like what you were mentioning dude1286.

Posted: 16 Jul, 2016 04:08
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".

Yeah null pointers cannot be assigned to constant pointers, it assumes it's volatile (address in memory changes immediately).

I could be wrong, but I think in the project properties you need to enable MBCS (Multi-Byte Character Support).
It's weird since wchar_t is part of C++ (not part of C).

If you don't mind reading alot, I would set the build verbosity to diagnostic. That definitely helped me a lot on my own projects.

Posted: 16 Jul, 2016 10:14
Last Edit: 16 Jul, 2016 15:25
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.

Posted: 16 Jul, 2016 15:19
Last Edit: 16 Jul, 2016 15:36
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.

Edit2: Nevermind, ImmenseGames is Scott (I think) and probably won't be available.

Posted: 18 Jul, 2016 16:36
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...

Thanks for your help nonetheless.

Posted: 11 Sep, 2016 02:20
Last Edit: 12 Sep, 2016 18:21
I was able to build RASnes9x in Visual Studio 2015 in Windows 10 and encountered the same errors. Here's steps to fix it (hopefully nothing is missing):

Clone RASuite
This assumes you have just cloned RASuite from GitHub... ("git clone ")

Note: The official repository mentioned on ][/url] is is [url='> .

First thing is to clone the whole repository locally so: "git clone ".

As mentioned, the project is dependent on an older version of rapidjson, specifically the ]v1.0 Beta release[/url] worked fine for me. By looking at the v1.0 Beta release worked fine for me. By looking at the [url='>"Tags" for the repository the tag for the Beta release is "v1.0-beta".

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 Errors
At 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 Errors
Now, 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 Errors
Try 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.

Temporary Fix: Open the file "MakeBuildVer.bat" and change the following line "@echo #define RA_INTEGRATION_VERSION "0.000" > ./RA_BuildVer.h" to "@echo #define RA_INTEGRATION_VERSION "0.053" > ./RA_BuildVer.h".

Code Details (the bug)
You will see the following message at the beginning of the build in the "Output" window: "RAIntegration Tag 0.000 - Not on Master Branch!"

This is because the build script "MakeBuildVer.bat" checks if the Git branch is the master branch:

    git rev-parse --abbrev-ref HEAD > Temp.txt
    @set /p ACTIVE_BRANCH=<Temp.txt
    @if NOT "%ACTIVE_BRANCH%"=="master" GOTO NonMasterBranch

If it is not the master, it always write a zero to a file called "RA_BuildVer.h":

    @echo RAIntegration Tag 0.000 - Not on Master Branch!
    @echo #define RA_INTEGRATION_VERSION "0.000" > ./RA_BuildVer.h

Very early in the code it checks the version ("RA_INTEGRATION_VERSION") by calling _RA_IntegrationVersion():

Which is implemented as:

    API const char* CCONV _RA_IntegrationVersion() {

The code that called it looks like this:

    return _RA_IntegrationVersion ? _RA_IntegrationVersion() : "0.000";

So it should be clear now that the version returned will definitely be zero (due to the macro). Now why does the assert happen?

Because of a bug triggered in this condition (probably not tested like this before)...

It starts in "RA_Interface.cpp" which does the following check:

    if( nVerInstalled < nLatestDLLVer ) {
        RA_Shutdown(); // Unhook the DLL, it's out of date. We may need to overwrite the DLL, so unhook it.

In this case, nVerInstalled is "0" and nLatestDLLVer is likely "51" or some non-zero number.

RA_Shutdown() immediately calls _RA_SavePreferences():

    API int CCONV _RA_Shutdown() {

_RA_SavePreferences has the following line toward the top of the function:

    fopen_s( &pf, std::string( std::string( RA_PREFERENCES_FILENAME_PREFIX ) + g_sClientName + ".cfg" ).c_str(), "wb" );

The problem is "g_sClientName" is null so it gets passed to string library as a null pointer. Why is it null?

It is initialized to null at the top of RA_Core.cpp:

    const char* g_sClientName = nullptr;

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.

Posted: 19 Nov, 2016 12:27
Great guide, thanks !
Page: 1 2 3 >


login to RetroAchievements:
or create a new account