I am trying to run a code on VSCode on Mac OS Catalina 10.15.2.
I am getting this Error on this function.
$ g++ main.cpp
Undefined symbols for architecture x86_64:
"nalea(int)", referenced from:_main in main-508a59.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
This is the main file I am using -
#include<iostream>
#include "proba.h"
#include "constantes.h"
#include "affichage.h"
int main(){
int a = nalea(60);
std::cout<<a;
//int a = InitAffichage();
return 0;
}
This is the proba.cpp file from where the function is called.
#include <cstdlib> // pour rand()
#include <cstdio> // pour fprintf()
#include <cmath> // pour floor()
#include "proba.h" // types et déclaration des fonctions
int nalea( int max)
{
return (int)floor(rand()*((float)max)/RAND_MAX );
}
This is proba.h header file
int nalea(int max);
Please help me, I am new to C++....