User forums > Using Code::Blocks

undefined reference

(1/1)

atap3d:
I have 3 files:
main.cpp:


--- Code: ---#include "el.h"

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

el.h:


--- Code: ---#ifndef __EL_H
#define __EL_H

#include <stdio.h>

void printhw(void);

#endif
--- End code ---

and el.cpp:


--- Code: ---#include "el.h"

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

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.

Navigation

[0] Message Index

Go to full version