Extremely stupid question related to error: undefined reference to `MainComponent::MainComponent()'

Hi all,

Excited to be finally making the leap into ‘real’ software programming!

I’ve been able to compile and run the GUI app helloworld on the same system that when I intend to build from scratch following the MainComponent tutorial (https://docs.juce.com/master/tutorial_main_component.html) I then get linking errors.

I can’t understand what I’ve done wrong, but it must be something simple, because`it’s literally as simple as a JUCE GUI app gets!

If anyone can figure out what the dumb mistake is, I’d be very grateful. Thank you!

This is the error I get:

build/intermediate/Debug/Main_90ebc5c2.o: in function `MainWindowTutorialApplication::MainWindow::MainWindow(juce::String)':
/home/arif/JUCE Projects/MainWindowTutorial/Builds/LinuxMakefile/../../Source/Main.cpp:66: undefined reference to `MainComponent::MainComponent()'
collect2: error: ld returned 1 exit status

Here is my code:


Note: deleted source code because it’s fine

This is a linker error, telling you that After compiling all source files the linker can‘t find the compiled version of MainComponent. So it seems that you don’t compile MainComponent.cpp. Did you add this file to your project in the projucer?

Side note: You set your components size in the destructor. Although unrelated to this error, I‘m quite sure that‘s not what you want to do :wink:

Ah yes! Well spotted, and, I’m really sorry for making you do my debugging for me!

Regarding your question, yes, I’m working only in Projucer and then using ‘make’ to compile.

I right-clicked on ‘Source’ then 'Add new Component class (split between a CPP and header)

Although Breakthrough I just closed and reopened the project, and MainComponent.cpp and Maincomponent.h do not appear, even though they are there in the same directory.