I have a relatively large project and I am using the same syntax as in a previous version of the project where it worked fine.
in file Main.cpp:
#include "Note.h"
#include <iostream>
#include <fstream>
using namespace std;
std::ofstream *notaFile;
int main(int parameterCount, char **parameterList) {
notaFile = new std::ofstream("Notation.txt", ios::out);
}
in file Note.h
extern std::ofstream *notaFile;
in file Note.cpp
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void Note::setPitchWellTempered(int absPitchNum) {
*notaFile << "Octave Number " << octaveNum << endl;
}
when linking:
lib/liblcmod.a(Note.o): In function `Note::setPitchWellTempered(int)':
CMOD/src/Note.cpp:117: undefined reference to `notaFile'
collect2: ld returned 1 exit status