News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

undefined reference

Started by atap3d, June 07, 2008, 12:59:54 PM

Previous topic - Next topic

atap3d

I have 3 files:
main.cpp:

#include "el.h"

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


el.h:

#ifndef __EL_H
#define __EL_H

#include <stdio.h>

void printhw(void);

#endif


and el.cpp:

#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?

McZim

Hello, file el.cpp should be include in the your project.

Project->Add Files.

atap3d

Yes, I know it. Of course, I included this file in my project.