codeblocks – C++ undefined reference to [email protected] (Code::Blocks)

codeblocks – C++ undefined reference to [email protected] (Code::Blocks)

I just had the exact same problem working with the exact same tutorials.

How to solve this?
I found that restarting CodeBlocks gets rid of this error. It has nothing to do with how you created the files or any of your syntax. A restart does the trick.

Why does this occur?
If I had to take a wild guess, I would think that CodeBlocks does indeed create the header/cpp files, it does not however link them to your project in a proper way that makes them usable (although it does ask you to link them to the project after you create them). This is a guess.

I understand that some people have commented on this by saying that youre creating a Windows GUI console application instead of a console application, but this is not the case. I too was creating a simple console application as Bucky explains in the videos.

Try this:
Settings->Compiler, click the tab Build options, select the checkbox

Explicitly add currently compiling files directory to compiler search dirs


Next time when you create a new class, in the File policy section, make sure you select checkboxes

  • Add path to project

  • Header and implementation file shall be in same folder

However, do NOT select

Use relative path

codeblocks – C++ undefined reference to [email protected] (Code::Blocks)

Go to Project --> Build Options . . . on menu bar
Go to Linker Settings tab
In Link libraries panel, click Add
Write this in the coming up field: mingw32;libSDL.a;libSDLmain.a
Go to Search directories --> Linker tab
Add your MinGW library folders there! Good Luck!!

Leave a Reply

Your email address will not be published.