Page 1 of 1

How to add a file to the engine

Posted: Sun Jan 22, 2023 3:34 am
by chronologicaldot
I ran into a snag lately. I want to add a class with its own files to the engine, but I don't know exactly how to include them.
I have a class called CIrrDeviceCustomPresenter, inside a .h and a .cpp with the same name.
In the Makefile, I assume the following:

Code: Select all

CUSTOMPRESDEVICE = CIrrDeviceCustomPresenter.o

# Next variable is for additional scene nodes etc. of customized Irrlicht versions
EXTRAOBJ = $(CUSTOMPRESDEVICE)
However, when I try to compile - and everything compiles fine, no errors - the object file CIrrdeviceCustomPresenter.o has next to nothing in it, unlike the other .o files for everything else. And as expected, I end up with linker errors complaining my class constructor doesn't exist. I didn't name my functions wrong or make any syntax errors. I checked again and again. The issue seems to be the compilation of my object file.

So there's the question: How do you add files to the engine so they compile correctly with everything else?
I've done this before, but I forgot.

Re: How to add a file to the engine

Posted: Sun Jan 22, 2023 3:47 am
by chronologicaldot
Update: Turns out, I was depending on a precompiler variable that I set in IrrCompileConfig.h ... and I forgot to include that file at the top of my header CIrrDeviceCustomPresenter.h
The object file is full now, but I still have the linker problem.

Re: How to add a file to the engine

Posted: Sun Jan 22, 2023 5:25 am
by chronologicaldot
Update: Found the issue. In the .cpp file, I had ifndef but in the .h I had ifdef for the same variable indicating when to compile. Makes a big difference one letter "n", doesn't it?