Well that feels like multiple steps back to get in the exact same place, but this is actually progress.
See what had happened was…
Until discovering KDevelop I spent too much time relying on Eclipse once I configured it to just work. And it did and it does. But eventually I’d like to move away from Eclipse to KDevelop. Meanwhile, I was not able to compile using my other default build system of (GNU) Make and a Makefile.
This is why you “get real” as many developer often suggest. It had been a while since I built to the target device (GameShell) and clearly I added content to the project that didn’t build correctly.
So the basic/real issue here is that the build system using Make was broken.
After trying a lot of other fancier solutions, I decided to whittle down the problem domain to the simplest problem. And also heeding the advice of other developers I did so by ditching the IDE’s altogether, if only temporarily.
I spent a while trying different things just on the command line in vim and directly using cmake, make, g++, gcc, and g++ yesterday but never quite got to the answer. It was mostly just figuring out what didn’t work. Today I ran across a Stack Overflow post where someone was trying to mix .c and .cpp files in their Makefile. I noticed a curious thing that they were able to use g++ instead of gcc to compile their c source code along with c++. So I added a build object for cJSON.c, the source that gave me these errors and it compiled!
~/projects/sdl2-pre-cjson master~5 ❯ make rm -f ./.depend g++ -w -MM src/Collision.cpp src/GameObject.cpp src/UIText.cpp src/MusicManager.cpp src/main.cpp src/Game.cpp src/Map.cpp src/ECS/ECS.cpp src/TextureManager.cpp src/Vector2D.cpp src/AssetManager.cpp src/UINineSlice.cpp>>./.depend; g++ -c -o src/UIText.o src/UIText.cpp g++ -c -o src/main.o src/main.cpp g++ -c -o src/Game.o src/Game.cpp g++ -c -o src/Map.o src/Map.cpp g++ -c -o src/UINineSlice.o src/UINineSlice.cpp g++ ./src/Collision.o ./src/GameObject.o ./src/UIText.o ./src/MusicManager.o ./src/main.o ./src/Game.o ./src/Map.o ./src/ECS/ECS.o ./src/TextureManager.o ./src/Vector2D.o ./src/AssetManager.o ./src/UINineSlice.o -w -lSDL2 -lSDL2_image -lSDL2_mixer -o sdl2-2d-game-engine ~/projects/sdl2-pre-cjson master~5* 8s ❯ ./sdl2-2d-game-engine zsh: segmentation fault (core dumped) ./sdl2-2d-game-engine
Errr…well at least it compiled. (This error is actually from a previous commit hash that lacked the new offending code. Turns out the error causing the segfault was actually just needing to run a
make clean before running make again.
Now compilation and running both work from the Makefile!
Now onward to actually making a game and such…
Et voilà, it’s running on device again!