No rule to make target `build/MyClass.o

Hello, I tried to add another class in an external file to my project but it doesn’t seem to be found. The file is in the project folder and VS Code shows it, I added it to the makefile, but apparently that is not enough.

I get the error

make: *** No rule to make target `build/MyClass.o', needed by `build/MyProject.elf'.  Stop.

My class itself is correct because it works fine when I copy all the code into the main file, but that would become quite unhandy.
Is there something else I need to do?

Can you share your Makefile?

I think I got a bit closer. Now I get the error

/Library/DaisyToolchain/0.2.0/arm/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: region `FLASH' overflowed by 106104 bytes

So my program gets tree times as large when I have a class in an external file, although the overall code is exactly the same. Maybe there is some linker flag I have to add or so?

The Makefile is just the one the helper.py produced, with MyClass.cpp added.

# Project Name

TARGET = MyApp

# Sources

CPP_SOURCES = MyApp.cpp MyClass.cpp

# Library Locations

LIBDAISY_DIR = ../../libDaisy/

DAISYSP_DIR = ../../DaisySP/

# Core location, and generic Makefile.

SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core

include $(SYSTEM_FILES_DIR)/Makefile

Oh crap, I had removed the debug code from the file but left

#include <iostream>

in it. That solved the “FLASH’ overflowed” problem.

I don’t actually know what fixed the initial “No rule to make target” error though…

It works perfectly again.

1 Like