Linking a header and a source file in CodeBlocks

Embrace_It

New Member
Reaction score
9
I have made a header file and a source file in C++. Inside the header is the declaration for a class. Inside the source file is the implementation. I am using CodeBlocks as an IDE.

I added both files to an empty project and compiled. I get numerous error messages, some, if not all, originating from the first error: "CAnimation.h: No such file or directory".

I was under the impression that IDE's normally link the code for you when you add them to a project. If this is not the case I would like some help with proper linking :)
 

Xienoph

You can change this now in User CP.
Reaction score
43
I haven't used CodeBlocks, but you're probably looking for "include" compiler parameter. Look around for that, and include the header files in there.
 

Xienoph

You can change this now in User CP.
Reaction score
43
Nope. In gcc, you specify it as "-l". Called the "search path". I think VS2008 called it "include" directory.
 

Samael88

Evil always finds a way
Reaction score
181
Why don't you just switch to dev-c++ instead?
It seems to be easier to use:)

Sorry if I sound rude:eek:
 

Weegee

Go Weegee!
Reaction score
102
Why don't you just switch to dev-c++ instead?
It seems to be easier to use:)

Sorry if I sound rude:eek:

Or VC++ :)

unless you are already on a project in CodeBlocks. However, its a bit complicated to use. If your a beginner I recommend that you use dev-c++
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Or VC++ :)

unless you are already on a project in CodeBlocks. However, its a bit complicated to use. If your a beginner I recommend that you use dev-c++

Lol who would do that? VC++ only works on windows. 'Nuff said.
 

Embrace_It

New Member
Reaction score
9
Yeah, I actually was using dev-c++ before, but the tutorial im following uses CodeBlocks as its IDE, so it was easier that way, and I actually like it...

Anyways, I'll ask around meanwhile. Thanks for your answers. If you have some other advice please tell me :)
 

Samael88

Evil always finds a way
Reaction score
181
If you are using SDL then I suggest you to use dev-c++ as it is the easiest one to use it with;)

I am also learning how to use SDL, and I have tried both dev, codeblocks and vc++, and I found that dev was the easiest one out there. May be beacuse I was used to coding in turbo c++ before, but that is a dos IDE:p


I would also suggest you using this aswell:
http://lazyfoo.net/SDL_tutorials/index.php
Since that page you are reading from don't cover everything and lazyfoo's tutorial does not either, but they kind of complete eachother;)
 

Omni

Ultra Cool Member
Reaction score
37
self made header files:

wrong
Code:
#include [B]<[/B]Myheader.h[B]>[/B]

right
Code:
#include [B]"[/B]Myheader.h[B]"[/B]
 

Embrace_It

New Member
Reaction score
9
Thank you Omni! That was exactly the source of the problem :) +rep

@ Samael88: I have already checked out LazyFoo's stuff, and I agree that they both complement each other. Since you were so nice as to give me a link, I'll provide one as well.

He does some basic stuff and also entire games like pong, tetris and breakout.

This might have some interest as well...

Thank you all! :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top