CAPI handler function wasn't located in loaded data

Hi there,

I’m using c api to make a playdate game with Visual Studio 2019 on Windows 10. Installed Playdate SDK 1.7.0 on PC as well as updated console to 1.7.0 version.

After compiling c game, the created .pdx file is running fine on simulator. But when I try to run same .pdx on console, it shows CAPI handler function wasn’t located in loaded data on screen. The game doesn’t run.

Any clue what might be up with it? I can provide more info, but not sure what to look for. So feel free to ask.

Thanks in advance!

1 Like

You have this message usually when the game doesn’t include binaries build for the device using the arm toolchain. Until know visual was probably just building you c code in a dll that is loaded by the simulator. The playdate cannot load that dll.

To build the arm binaries depends a bit of how you are setup but from the documentation, if you used visual studio, it seems you just need to build a Release version.

Hi Nic,

Thanks for that bit of info.

I used cmake .. to generate Visual Studio project. And I selected Release from Solution Configuration dropdown menu to build the game. But still no luck.

For second test, I used cmake -DCMAKE_BUILD_TYPE=Release .. to generate Visual Studio project. But got CMake Warning,

Manually-specified variables were not used by the project:

So no luck there. Though it’d align with your observation that for Visual Studio, maybe all I’m supposed to need is select Release config from IDE.

Third test, and only way I was able to run Hello World template project on device is by using nmake to build .pdx. On Inside Playdate with C.html, that’s

4.5 Building for the Playdate using NMake

My current project has multiple .c files as sources though. Not sure what updates I need to make in CMakeLists.txt to have nmake recognize all the other c files & not only main.c. If building through nmake works for this project, that’s fine too.

Do you get any build log when you build in Release?

In theory building for arm should spit a file ‘pdex.bin’ in your playdate project (where pdxinfo should be)

Also for reference I use aux_source_directory in cmake to include all the files of a directory. There might be a better or cleaner way but it works for me.

cmake_minimum_required(VERSION 3.14)

		COMMAND bash -c "egrep '^\\s*SDKRoot' $HOME/.Playdate/config"
		COMMAND head -n 1
		COMMAND cut -c9-

# Game Name Customization

aux_source_directory(src/ PROJECT_C_SOURCE_FILES)


	add_executable(${PLAYDATE_GAME_DEVICE} ${SDK}/C_API/buildsupport/setup.c ${PROJECT_C_SOURCE_FILES})

1 Like

Thanks for that CMakeLists.txt! Using aux_source_directory worked nicely for me. Previously I tried manually typing in all the .c files but nmake was failing because of different reason. It turns out if I don’t have Source folder created manually, nmake fails with bunch of error about not being able to access files from it. I got one way of making Playdate builds sorted out now, at least.

About the Visual Studio’s Release build output, let me get back to you next week. My guess is VS don’t switch to arm-gcc compiler on Release config and it keeps using whatever the default Microsoft c compiler it is configured to use (same as Debug builds).

VS doesn’t switch to the arm compiler for release builds (it doesn’t know anything about gcc-arm), so you will need to use the arm toolchain directly. The easiest way is using a cmake file with the arm toolchain option which is outlined in the inside C docs.

1 Like

Thanks, Will! Can confirm these steps worked for me,

Building for Playdate Console

I have had success with nmake.

  1. Open x64 Native Tools Command Prompt for VS 2019 from Start Menu
  2. Go to build directory of the project
  3. Execute command cmake .. -G "NMake Makefiles" --toolchain="SDK_PATH\C_API\buildsupport\arm.cmake"
  4. Execute command nmake

Note: I had to make sure that Source/ folder was created before running make steps.

I got the same error -- CAPI handler function wasn't located in loaded data. I'm on Linux and using a Makefile directly instead of CMake. I'm not sure what argument to provide to build for arm.

Edit: ah, I understand -- a .bin file is produced, which is intended to run on the device.