Standalone Build Tools for VS are incorrect architecture for Playdate examples

,

Howdy all,

I'm writing a series of tutorials for setting up new computers for Playdate development and am running into an issue trying to build the C examples using the standalone Build Tools for Visual Studio 2022.

It makes sense that the standard operating procedure is to simply download/install the entire VS 2022 IDE, but I'm trying to cover some alternative options for the sake of thoroughness.

The Inside Playdate for C page has the instructions for building examples using VS Code and NMake (Inside Playdate with C), but assumes the user has the Developer Command Prompt, which is not included with the standard VS Code download.

There are two ways to get it -- download VS 2022 or the Build Tools for VS 2022.

The problem is the standalone Build Tools seem to be set to 32-bit by default. On Windows, they even install under Program Files (x86).

When following the steps laid out in the SDK documentation (create build folder, cmake .. -G "NMake Makefiles", nmake), it does successfully build a .pdx in the example's root directory, but attempting to load it into the Simulator returns the following error:

14:30:29: SDK: P:\PlaydateSDK
14:30:29: Release: 2.5.0
14:30:29: Loading: P:\PlaydateSDK\C_API\Examples\Hello World\hello_world.pdx
Loading C API game: P:/PlaydateSDK/C_API/Examples/Hello World/hello_world.pdx/pdex.dll
LoadLibraryA() failed: (193): P:/PlaydateSDK/C_API/Examples/Hello World/hello_world.pdx/pdex.dll
14:30:29: Loading: OK
Update error: Library architecture mismatch. Try rebuilding with the 64 bit toolset.
14:30:29: Update failed, simulator paused.

I've also tried to build using some of the other prompts included with the Build Tools (like x64 Native) to force it to 64-bit. They all generate a .pdx and they all fail to open in the Simulator with the same error.

Curious if anyone can lend some insight as to what's going on here and any potential solutions (other than the obvious... just use Visual Studio 2022).

Thanks!

If you are using the Visual Studio Installer you should be able to select the architecture you need, I think? e.g.

I am using the build tools downloaded from this page: Download Visual Studio Tools - Install Free for Windows, Mac, Linux

As an addendum, these are the steps I wrote in my C hello world project set up instructions, maybe they will help:

Set the VISUAL_STUDIO_TOOLS environment variable to the path to vcvars64.bat. One way to find this is detailed below:

  1. You can find the location of it by going to the start menu, typing "x64 Native" and seeing what comes up.
  2. Right click on it and Open File Location.
  3. Explorer will pop up with some shortcuts to open command prompts. Right click the x64 shortcut and select Properties.
  4. In the Shortcut tab, in the Target property, copy the path to vcvars64.bat. On my machine, after installing VS 2022 tools, the value was C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build.

Alex, I really appreciate you looking into this with me.

I'm going to double-check the components installation (opted for the default C++ for Desktop workload initially) and try to re-route the prompt path.

Will report back with the results.

1 Like

Update: Thank you, Alex!

All the necessary componenets were installed, the x64 Native Tools Start shortcut was pointing to the correct location... but I'd forgotten to update the Environment Variables with the path to the folder that contained vcvars64.bat

It's always the little things, innit?

Made that change, rebuilt with nmake in the x64 Native prompt, and everything's working smoothly now.

I was on the verge of writing the Build Tools out of that section entirely, but this is an easy fix.

P.S. Your GitHub setup tutorial is a really great resource -- thanks for including the link!

1 Like

This is great to hear, glad you got it sorted!