I have 3 files: - main.cpp - other.cpp - other.h
I am trying to call a function that was declared in other.h, from main.cpp, with the code being written in other.cpp
My code:
main.cpp:
//#Allmyincludes
#include "other.h"
int main(int argc, const char *argv[])
{
const char *file = argv[1];
read(file);
return 0;
}
other.cpp:
//#Allmyincludes
#include "other.h"
void read(const char *file)
{
//code
}
other.h:
void read(const char *file);
The error I get is:
main.cpp:(.text+0x44): undefined reference to 'read(char const*)'
Within read(), I am using main::variableName to access variables from within main (no errors), however I just can't get the function call to work.
If I try to do other::read(file); that also doesn't work because :: is for functions and not files. It gives me the error: 'other' has not been declared.
Any explanation as to why my header file/call isn't working is greatly appreciated.
g++) notice that order of program arguments to the compiler matters a big lot.