Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: atap3d on June 07, 2008, 12:59:54 pm

Title: undefined reference
Post by: atap3d 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?
Title: Re: undefined reference
Post by: McZim on June 07, 2008, 02:09:52 pm
Hello, file el.cpp should be include in the your project.

Project->Add Files.
Title: Re: undefined reference
Post by: atap3d on June 07, 2008, 02:20:30 pm
Yes, I know it. Of course, I included this file in my project.