0

In c++ I follow a tutorial on youtube and I stranded with a prblem with my header file. I got 3 files Main.cpp , Cat.cpp and Cat.h. In the duplicate post I can't seem to find an answer and the tutorial I follow has exactly the same code.

Main.cpp:

#include <iostream>

#include "Cat.h"

using namespace std;

int main(){
   speak();
   return 0;
}

Cat.cpp :

#include <iostream>

#include "Cat.h"

using namespace std;

void speak(){
  cout << "miauw" << endl;
}

and finaly Cat.h :

#ifndef CAT_H_INCLUDED
#define CAT_H_INCLUDED

void speak();

#endif // CAT_H_INCLUDED

build log:

-------------- Build: Debug in test (compiler: GNU GCC Compiler)-----------

mingw32-g++.exe -Wall -g  -c "C:\Users\73638G75MA\Documents\C++                 projects\test\Main.cpp" -o obj\Debug\Main.o
mingw32-g++.exe  -o bin\Debug\test.exe obj\Debug\Main.o   
obj\Debug\Main.o: In function `main':
C:/Users/73638G75MA/Documents/C++ projects/test/Main.cpp:8: undefined reference to `speak()'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
miquel09
  • 144
  • 1
  • 1
  • 12

0 Answers0