0

I have the following problem (i'm still very unexperienced when it comes to libraries)

i have this 3 files, in the same folder, the main.cpp, prova.h, prova.cpp

main.cpp

#include "prova.h"
int main(){
  myprova(245);
  return 0;
}

prova.h

void myprova(int a);

prova.cpp

#include<iostream>
#include"prova.h"

void myprova(int a){
  std::cout<<"buongiornissimo"<<a<<endl;
}

when i hit (on atom, with the gpp-compiler from kriscors07) build and run, it just tells me i have an undefined reference on myprova i have also tried leavingt the #include "myprova.h" line in the myprova.cpp file, but it's the same.

compiler error

/tmp/ccS6gADM.o: nella funzione "main":
main.cpp:(.text+0xa): riferimento non definito a "myprova(int)"
collect2: error: ld returned 1 exit status

Halp?

Ema Pall
  • 11
  • 2
  • 5
    Including a header ≠ linking. You have to *compile* `prova.cpp` and *link* it with the rest. – Biffen Sep 20 '18 at 11:02
  • That other question has a lot of details about different possible causes, but it's https://stackoverflow.com/a/12574400 in particular which is relevant to you. –  Sep 20 '18 at 11:23

0 Answers0