PlayDate and building for Sim vs Device problems

I programmed a small game in Visual Studio 2022 and it uses Chipmunk2d physics engine and it works great in the Simulator. But when I go to compile it for the PlayDate using the command line: cmake .. -G "NMake Makefiles" --toolchain=C:\PlayDateSDK\C_API\buildsupport\arm.cmake that command works right. Then I do nmake and it looks like it's going to go then fails:

main.c.obj : error LNK2019: unresolved external symbol _cpArbiterGetShapes referenced in function _preSolveCombine
main.c.obj : error LNK2019: unresolved external symbol _cpBodyNew referenced in function _CreateAgent
main.c.obj : error LNK2019: unresolved external symbol _cpBodyGetPosition referenced in function _update
main.c.obj : error LNK2019: unresolved external symbol _cpBodySetPosition referenced in function _preSolveComb

And there's more.

I am new to C (but I've coded in Java, JS, PHP, C#, etc) and this is confusing me as all get up. I spent 2 days trying to use Google, Bing, ChatGPT, Bard and more to find out why it's not working. I thought maybe I need to compile chipmunk for arm as well but couldn't figure that out.

Can someone smarter than me please explain what the heck I'm doing wrong.

Thanks so much!

Disclaimer: I don't have experience building C for Playdate on Windows, but I have some general knowledge of building C.

It looks like a linker error. The Chipmunk2D lib file is missing. It could be a CMakeList.txt misconfiguration. It will help if you show your CMakeList.txt or, better off, include a complete minimal reproducible example.

Also, there are people here who've built Chipmunk2D. Both posts have source code included. Perhaps, they could help you out too.

The thing is, if that was the case it wouldn't compile and work in the simulator. It works 100% for the simulator. It's only when I try to compile it using nmake and cmake for the ARM (for the playdate hardware) that I get those errors.

It just confuses me that it'd work using the libraries in the sim, but not for the playdate. Those things didn't just magically disappear. They are all in the same spot, named the same things, etc

I think because the device and the simulator are two different targets in the example CMakeLists.txt file, you might be adding the library to one and not the other.

# Game Name Customization
set(PLAYDATE_GAME_NAME hello_world)
set(PLAYDATE_GAME_DEVICE hello_world_DEVICE)

project(${PLAYDATE_GAME_NAME} C ASM)

if (TOOLCHAIN STREQUAL "armgcc")
	add_executable(${PLAYDATE_GAME_DEVICE} src/main.c)
else()
	add_library(${PLAYDATE_GAME_NAME} SHARED src/main.c )
endif()

I personally handled this in my project by adding another if statement:

if (TOOLCHAIN STREQUAL "armgcc")
	target_link_libraries(${PLAYDATE_GAME_DEVICE} opusfile speex_resampler stb_image)
else()
	target_link_libraries(${PLAYDATE_GAME_NAME} opusfile speex_resampler stb_image)
endif()

If that's not it, then you really should post your CMakeLists.txt file.