Author Topic: undefined reference  (Read 3230 times)

atap3d

  • Guest
undefined reference
« on: June 07, 2008, 12:59:54 pm »
I have 3 files:
main.cpp:

Code
#include "el.h"

int main(int argc, char* argv[])
{
printhw();
return 0;
}

el.h:

Code
#ifndef __EL_H
#define __EL_H

#include <stdio.h>

void printhw(void);

#endif

and el.cpp:

Code
#include "el.h"

void printhw(void)
{
printf("Hello my master\n");
}

If I build it by typing "gcc main.cpp el.cpp" in terminal - all ok. But if I build it in Code::Blocks I get error "main.cpp:(.text+0x2b): undefined reference to `printhw()'". Why?
« Last Edit: June 07, 2008, 01:02:23 pm by atap3d »

Offline McZim

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: undefined reference
« Reply #1 on: June 07, 2008, 02:09:52 pm »
Hello, file el.cpp should be include in the your project.

Project->Add Files.

atap3d

  • Guest
Re: undefined reference
« Reply #2 on: June 07, 2008, 02:20:30 pm »
Yes, I know it. Of course, I included this file in my project.