How to set up new C++ SynthComponent in a new project without compiler errors?

I’m getting an error that I’m unsure how to solve. Luckily my issue should be very easy to replicate for anyone willing to help. Here are the steps I take…

-I have downloaded and installed UE4 with the latest version.
-I start a new project (C++ based w/ basic code and starter content)

  • I name the project ‘MyProject’

Once the new project loads…

  • I click File>New C++ class
  • I choose the option to show all classes
  • I choose the class type ‘SynthComponent’
  • I name the new component ‘MySynthComponent’ and click to create the new C++ class

Unreal Editor then tries to create the new C++ component. Here is where I get a compiler error.

A notification window shows up that says:

"Successfully added class ‘MySynthComponent’, however you must recompile the 'MyProject module before it will appear in the content browser. Failed to automatically hot reload the ‘MyProject’ module.

There is a red warning in the log:

“request failed. libcurl error 6: (Couldn’t resolve host name)”

Then there are some errors to follow:

“ERROR: UBT ERROR: Failed to produce item: MyProject\Binaries\Win64\UE4Editor-MyProject-502.dll”

Ignoring these errors, I tried clicking the ‘Compile’ button at the top of the editor. Compilation fails again, and the output points me to an apparent error in the SynthComponent template class:

" error C2555: ‘UMySynthComponent::OnGenerateAudio’:overriding virtual function return type differs and is not covariant from ‘USynthComponent::On GenerateAudio’ "

I don’t really understand what the error means, but it seems to have to do with the MySynthComponent class I have created. In side that newly created class, the ‘OnGenerateAudio’ function is declared as having a void return type, but the return type of the function it inherits from is int32.

Seeing as I’m only trying to use a built in engine template (the USynthComponent type), I’m not sure if I’m doing something wrong or have found a bug? Either way I’m pretty lost; am no programming expert, and am switching over to Unreal from Unity, so I’m unsure what I’m dealing with on more or less every level here!

Any help in simply setting up a new Synth Component type without these compiler errors will be greatly appreciated. The Synth Component is supposed to generate a simple sound tone by generating a sine wave buffer in the C++ by the way.



virual functions always must have the same signature (same parameters and same return type) as their base version. This is required because the function in your derived class might be called from a pointer to the base which does not need to know anything about your implementation. Basically this is one of the major advantages of virtual methods. Just adjust your code to match the original functions signature and it should compile.

The libcurl message seems to be an failed DNS lookup and should be rather independent of the other errors.

You are correct. The issue is solved now and I am about to post the solution for clarity. Thanks for the reply!


Some small modifications to the code needed to be made.

1) Add “AudioMixer” as a parameter in MyProject.Build.cs

This is required because the new class will inherit from AudioMixer.

2) Change the virtual void OnGenerateAudio() function in the newly generated class to a virtual int32 function

j.mueller’s answer can explain why this was necessary, but nothing has yet explained why the class wizard creates the new class with virtual void functions that can’t compile because they inherit from virtual int32 functions…

So anyway, this just means changing the keyword for the OnGenerateAudio() function from “void” to “int32” in the .h and .cpp files for the new class, and also adding the line “return NumSamples;” at the bottom of the function definition.