Author Topic: [SOLVED]Problem with linking *.h files.  (Read 3445 times)

wojciech

  • Guest
[SOLVED]Problem with linking *.h files.
« 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.
« Last Edit: March 04, 2009, 02:04:05 am by wojciech »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Problem with linking *.h files.
« Reply #1 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.

wojciech

  • Guest
Re: Problem with linking *.h files.
« Reply #2 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 :)