C_API/Examples: syntax errors in Makefiles?

Day 3 and I'm still fighting trying to get the "Examples" to actually compile.

As previously noted, only a couple of the C Examples use cmake. The rest apparently require the use of Nmake.

In trying to compile "Array", "nmake /P /NOLOGO /F .\Makefile", I get this error:

".\Makefile(7) : fatal error U1001: syntax error : illegal character '{' in macro"

Line 7 is this "SDK = ${PLAYDATE_SDK_PATH}"

I changed the curly braces to parens and cleared up that error. Does nmake not like curly braces? Doc seems to not mention it.

After fixing that I get an error at line 9:

".\Makefile(9) : fatal error U1034: syntax error : separator missing"

Line 9 is:
ifeq ($(SDK),)

After I RTFM'd, it's clear that ifeq() is missing an argument.

At this point it became clear to me that most of this cr..., er, code, has not been debugged, or in this case, ever run on Windows. This is extremely frustrating. I'm not going to bother filing a bug on this; it's not my job to debug Panics code.

The Windows example projects only run with the cmake files, not the make files. If you haven't already, please read the Inside Playdate with C documentation on how to get it set up and running on Windows.

Thank you for the reply. I've read the Playdate with C doc and after reading though the slightly clear explanations, my results are below.

This is my build and test procedure:

  1. copy CMakeLists.txt to the top directory of the Example.
  2. making a "build" directory at the top level of the Example
    3 cd build ; make ..
  3. Build the Xproj using Visual Studio 2019
  4. Drag and drop the .pdx directory onto the running simulator

I've just tested everything. Results are below. It's entirely possible that I've mis-configured something given that the PD w/ C directions reference multiple OS's and tools and information on using Cmake is spread across multiple sections.

Array doesn't work - build fail references Hello World
CMake Error at CMakeLists.txt:35 (add_library):
Cannot find source file:
src/main.c
Exposure doesn't work
Fails same way as Array
Life doesn't work
Fails same way as Array
Sprite Game doesn't work
Fails same way as Array
3D Library
Fails same way as Array


Hello World works

Json works (at least compiles and loads)

bach works

Particles works

At this point I'm giving up on the examples and just diving into coding.

Are you creating make files, or nmake files? You note make in your steps, just making sure you're using nmake.

This section of the docs should tell you all you need to do to get set up on Windows, but you need to follow it exactly.

As noted previously, many times, I have read that section of the documentation. I have followed it. That's why some of the Examples DO compile. Please feel free to try my described procedure,

1. copy CMakeLists.txt to the top directory of the Example.
2. making a "build" directory at the top level of the Example
3. cd build ; make ..
4. Build the Xproj using Visual Studio 2019
5. Drag and drop the .pdx directory onto the running simulator

... in any of the following Examples:

Array, Exposure, Life, Sprite Game, 3D library

If they DO work for you, on Windows, using cmake and Visual Studio, I will thank you and take it to hear that I've missed something in my toolchain install, and go back and reinstall everything.

Kind regards,

Side Note: all of hte Lua examples I tested compiled and worked easily using pdc then drag and drop to the Simulator

If I'm understanding what you're saying correctly, you've copied a CMakeLists.txt file from an example project and added it to the examples that don't have one and tried to build them. If that is the case, you'll need to modify the CMakeLists file to build that specific project.

Will, that's what I thought also. But section 3.2.1 of the Inside PDw/C says

" Add a CMakeLists.txt file to your project using the one from this project as a template"

(Also, I'm not using CLion so I initially skipped over that comment.)

It doesn't specify what "this project" is, but I was able to get Hello World, and some of the other examples, to working using the same file. I figured that since these were examples they would follow a common set of rules. Clearly I was wrong. But now I have much lower expectations as to the quality of the SDK so I'm adjusting my approach to things and moving on to battling the C API vs. the Lua API.

Regards,

Robert

I'm following this thread and I also can't build a few of the C_API examples from a fresh install of the SDK. I had to copy the CMakeList from another project and modify it in order to build.

Will the SDK be open sourced or allow individuals to contribute. I think some of the examples needs some polish.

1 Like

I just tried the following with the Array example using newly generated nmake files and had no issues.

(in vs community 2019 x64 shell with included cmake)

  1. Copy the CMakeLists.txt from HelloWorld example into the Array example root
  2. Edit that to include main.c and array.c, and also to update game and device names
  3. make your build directory and cd to it
  4. cmake .. -G "NMake Makefiles"
    or for the arm device .
    cmake .. -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=%PLAYDATE_SDK_PATH%\C_API\buildsupport\arm.cmake
  5. nmake

I'm just going to assume none of the examples have working makefiles out of the box but the fix is easy enough given that it's the same process to create a custom project anyway.

Hope this helps.

3 Likes

We appreciate hearing everyone's notes on the SDK! Since we're a super small group, your input is valuable. We're working hard every day to make the Playdate SDK even better for you.

I also want to remind everyone that any thoughts or criticism you share here, while absolutely welcome, must be constructive — even if frustrated, please try to remember we're humans on the other end as you describe the issue you're running into, what you expect to happen, and how we can make the SDK better.

(In this particular case, describing our work as "crap" — even without the last two letters — is not necessary.)

It's of vital importance to us that this is a friendly, welcoming, safe community for everyone. If your default online voice is excessively negative, snarky, sarcastic, or aggressive, we'll ask that you discuss Playdate elsewhere.

You can learn more about the community guidelines here: FAQ - Playdate Developer Forum

Thank you so much!

4 Likes

I apologize to the team.

2 Likes