Cpp files don´t recognize the JucerHeader file

Greetings JUCE Community,

I’m currently facing an issue where my .cpp files in the JUCE framework are not recognizing the corresponding .h header files. This has caused compilation errors and prevented me from progressing with my project. I’ve tried various troubleshooting steps, including checking file paths, ensuring proper header inclusions, and updating the JUCE framework. However, the problem persists.

Here’s a summary of the issue:

When I attempt to compile my .cpp files, I receive compilation errors similar to "undefined reference to function name" or "no matching function for call to function name."

These errors are specifically related to functions or variables defined in the corresponding .h header files.



I've also updated the JUCE framework to the latest version.

I’m seeking assistance from experienced JUCE developers to identify the cause of this issue and provide a solution. Any insights or suggestions would be greatly appreciated.

Thank you for your time and consideration.

Some questions:

  • Standalone app or plugin?
  • A clone of the JUCE repo, or a .zip file unpacked into some path on your local machine somewhere?
  • What is meant by the term “JUCE framework [is] not recognizing the corresponding .h header files”? - that your compiler cannot find the JUCE headers, or is Projucer complaining about the Global JUCE Module path you’ve set in your project?

This is a fairly common problem and usually relates to the answer to one of the above questions not quite being correct, technically …

Some more questions:

  • How did you set up the project? CMake or Projucer?
  • What IDE/OS are you using?
  • What is the exact error message?

Most common mistakes:

  • Projucer: modules pointing to a different path
  • Projucer: forgot to re-save the project files
  • CMake: JuceHeader.h wasn’t generated at all, needs to be requested with juce_generate_juce_header()
  • Using old code where the namespace juce:: wasn’t used. Either add using namespace juce; or better add juce:: before any juce type.

With more data people can give more help.

Hi,
I am using Projucer + VS 22.
There is no actuall error message since I canť access the “not implemented code”.
Everytime I open a .cpp file it just has many errors. What has helped was writing:
#include JucerHeader.h and the errors dissaper.

For example:
class SaturationPlugin : public juce::AudioProcessor
{

public:
SaturationPlugin();
~SaturationPlugin();

void prepareToPlay(double sampleRate, int samplesPerBlock) override;
void releaseResources() override;

void processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override;

AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;

bool acceptsMidi() const override { return false; }
bool producesMidi() const override { return false; }
double getTailLengthSeconds() const override { return 0.0; }

AudioProcessorParameterGroup& getParameters();

The definitions for the functions prepareToPlay or processBlock are not found.

Thanks for any help.

Are you opening your project in VS2022, or just individual .cpp files?

Because the expectation that VS2022 knows about your project (i.e. where to find header files to include) if you are not opening the project, but rather just .cpp files, is incorrect.

How are you opening your project - from with Projucer, or independently using the VS2022 File|Open dialog?

I am opening my whole project in VS2022.
Sometimes I am opening the project trough Projucer sometimes trough the Project open dialog in VS.

I am making a plugin. I am using a clone of the JUCE repo using FORK. I guess the problem is with the modules and the compiler. Projucer isn´t complaining at all.

Have you told Projucer where your local copy of JUCE is located, and where its modules folder is located?

Yes, I have. I have set up the modules accordingly.

Okay then, something else is going wrong … how about you go through @daniel’s common mistakes list and double check you have things set up as expected?

This is the video of the problem. https://youtu.be/mt4yYPDUObY

I have. Can it be that, the include JucerHeader.h should be in every .cpp file, but for some reason my code doesnt have it.

Ok, I skimmed through the video:

  • don’t modify the juce files. If they were broken, we would know
  • don’t put #pragma once in cpp files

Those curly red lines in juce code is intellisense getting confused. That is an unfortunate issue the juce team is aware of but don’t know an easy way to fix it.

I see from the screenshot that you have added a VST SDK path. Do you try to build VST2 (legacy)? That needs extra checks, but if you want to make current VST, then it is VST3 and you don’t need to set anything. Best to clear that setting from projucer, just in case.

In the Projucer open the modules tab and select the modules one by one. There are too many ways to specify the location of the modules:

  • either set “Use global path” and it will use the path from your screenshot above
  • or set that off and make sure the path above is legit

Hope any of those things help. Otherwise we can continue there

All of my modules use the global path. So I think that can’t be the problem. I have tried to test some plugins and even they didnt work. I am going to reinstall my JUCE files because there is no way its something else. I am also thinking about cmake you mentioned earlier. Would downloading an earlier version of VS or JUCE help with my problem?

There is no need to switch to cmake, both ways should work for you.

VS is unlikely, in juce there is the chance you accidentally modified something while poking.
What would be crucial to make sure you are using the same Projucer version like the modules you are trying to build. Originally it was meant to only matter on major versions, but it can be flakey especially on the develop branch.

What others here would help to help is a screenshot of the actual error. It becomes a bit guesswork here.

This sounds really similar to a problem I’ve had with Visual Studio over the years, which is that Intellisense sometimes can’t see the Juce header. I think it’s because some of those header files don’t get build until compile time, and Intellisense isn’t smart enough to run all of the necessary macros before the code has been compiled for the first time. If you’re having the same issue as me, then it’s possible that Visual Studio will actually be able to compile the code just fine, and that the Juce related Intellisense errors will start to disappear once you’ve compiled it for the first time.

I assume that you’ve tried compiling it already and that it won’t run. In that case, it’s possible that there are other errors besides the reported Juce ones that are stopping it from compiling, and that once you solve those, the program will compile correctly. So look for errors that are not related to missing Juce classes and try to fix those. (This can be a pain because you probably have hundreds or thousands of errors, and you’ll have to go through the whole thing).

Yes, I am realizing that right now too. Everything is run just fine even though my VS is screaming.

Thanks everyone for the help.

I thin if it’s only intellisense complaining then my understanding is the latest version of VS fixes this issue.

That’s what I meant before:

There is a setting in the errors page:
Show: “Intellisense and Build errors” → switch to “Build errors only”
That removes the clutter

1 Like