Code::Blocks Forums

User forums => Help => Topic started by: wojciech on February 28, 2009, 11:55:32 pm

Title: [SOLVED]Problem with linking *.h files.
Post by: wojciech on February 28, 2009, 11:55:32 pm
Hi,

I have one big problem with C::B. I just don`t know how to link header, i wrote something like this:
//main.cpp
#include "foo.h"
int main(){
bar A;
A.show();
}
//foo.h
class bar{
public:
int qwerty;
int show();
};
//foo.cpp
#include "foo.h"
int bar::show(){
return qwerty;
}

And when I try to compile,build and run this i got error "undefined reference to show()", what exactly means that something went wrong with linkink these files. I have no idea how to show linker what to link. (before i was using Kdevelop, and there was no issue with linker)

Sorry for that pool above, my mistake.
Title: Re: Problem with linking *.h files.
Post by: Jenna on March 01, 2009, 01:14:44 am
If you have not yet created a project, do it now (wizard empty project).

Add both cpp-files and the header file, and that's  it.
Title: Re: Problem with linking *.h files.
Post by: wojciech on March 04, 2009, 02:03:12 am
Ok, now i got it. I didn`t mark option in wizard "in build targets". Now i marked both options (debug, release) and it works :)