My header file will not work. Codeblocks

0 Jebi Green · October 15, 2015
Hello everyone, I am a new member of this community and fairly new to C++ programming. I installed Codeblocks to follow Bucky's tutorials and haven't run into issues until the class in different files issue came up. I followed everything and have tried to create new projects and nothing is working. He says to #include "file.h" however when I do that I get an error in compiling.

I tried to look it up and the solution was putting #include "file.cpp" however when I do this and create an object it will not run the things in the compiler. I have everything the same as Bucky in the tutorial (even tried naming it Burrito once), however I have a more recent version of Codeblocks and have some things he doesn't. The only thing I see different in the process is the dialog box, there are two added options that are checked (which I have tried having each one checked alone and both not on at all as well as both checked and nothing is fixing the issue), the options are "Add paths to project" and "Use relative paths". I really need to figure this out because soon I will be doing a group project which he said you could just send the header file to use.

Here is everything I got:

/images/forum/upload/2015-10-15/7a69a72a4821513a00bb9d0dabac67d0.JPG       /images/forum/upload/2015-10-15/f973e824dba513ecafe15fb66a286814.JPG   



Thanks guys in advanced for the help!

Post a Reply


Oldest  Newest  Rating
+1 c student · October 16, 2015
is your header file in the same path as your cpp files?  or have you correctly located the header file when #including it?
0 Linguist Llama · October 16, 2015
This is a very common linker error! You can see how common it is by googling "undefined reference to"... There are multiple possible problems associated to this error message, but the gist of it is: Each module is compiling correctly; but the modules aren't being linked correctly.

Behind the scenes, Code::Blocks is using a command line program, typically gcc or clang, to compile your code. You need to know how to compile your program using the command line, otherwise you won't know how to configure Code::Blocks to link your code correctly.
+1 Timur Khuzin · October 16, 2015
I had the same problem on Win7.  Click your project with right button, select "build options". In the opened window go to "Search directories" section. In the Policy choose "Use Project options only".
After these actions your program will be built fine./images/forum/upload/2015-10-16/b658f9c26068f7e0aae6baf1a94389b1.JPG
0 Jebi Green · October 16, 2015
HEY GUYS! Thank you "c student"  so much for giving me the hint of the pathing, I fixed that and it was still not working but then doing what "Timur Khuzin" said to do and it worked perfectly! However this arose another question. First here is it working!

How would you send the header file and get it to work for another person working on a project with you? Bucky said you could just send the header and do the compiling on your own machine. How would one go about doing this?
+1 Linguist Llama · October 24, 2015
The command-line compiler that your Code::Blocks uses has a manual that describes how to use it. I recommend having a read of it, some time. It has some very useful "hidden features", some of which might not be exposed to you by your IDE, and besides... You never know when your IDE might break down, forcing you to revert to the console anyway!
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator