0

I just startet with C++ and i don't know whats wrong with this Code I already saw the same problem in other questions but the sources are too complex

Main.cpp

 #include <iostream>
 #include <climits>
 #include "print.h"
 int z = 3;

int main()
{
std::cout << z << std::endl;
print();
return 0;
}

print.h

#ifndef PRINT_H_INCLUDED
#define PRINT_H_INCLUDED
void print();    


#endif 

print.cpp

#include <iostream>

extern int z;

void print(){
std::cout << z << std::endl;
std::cout << z << std::endl;
}

The Error is "undefined reference to print()" Does anyone have an idea how i can solve that?

J. Dan
  • 89
  • 1
  • 4
  • 2
    Look over [this post](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix). An undefined reference is a **linker error** and that post goes over all of the things you should check to fix that type of error. – Cory Kramer Oct 04 '15 at 20:00
  • You're not invoking your compiler correctly. – Kerrek SB Oct 04 '15 at 20:05
  • @J. Dow you better jolt down the compiler command if you are still facing issues.. – jha-G Oct 04 '15 at 20:12

0 Answers0