I am very new to c++ and my tutor has given me a file to use and I cannot get it to compile. I get undefined error and I haven't got a clue how to fix it. It comes as three files. Any help would be greatly appreciated.
euler_main.cpp
#include <string>
#include <iostream>
#include <cstdlib>
#include <vector>
#include "euler.h"
int main(int argc, char *argv[]){
// Get n via the command line
if (argc==1){ // The first argument is always the program name
std::cout << "Call via \"euler n\", wher n is an integer." << std::endl;
return 1;
}
int n=atoi(argv[1]); // The second argument is n
// Define the needed vectors
std::vector<double> xvals;
std::vector<double> fvals;
std::vector<double> err;
// Perform the computation
double max_error = my_euler::euler(n, xvals, fvals, err);
// Output all values
my_euler::euler_output(xvals,fvals,err);
// Finally give out the maximum absolute error
std::cout << "The maximum absolute error is " << max_error << "." << std::endl;
return 0;
}
A general rule about programmers is that we're lazy. You're in for a long wait if you're expecting us to compile your code just to see what the error you got was, so if you want to get an answer anytime soon, you better post the error message.
Thank you so much for your help. I recieved the program as three seperate files. I tried to open them all and compile them seperately and that didn't work. So I opened a new project and inside that new project there is a main.cpp file. I copied the code from the euler_main.cpp into that file. I then created a new c++ source file inside the sources folder and copied the euler across. I then created a header and did the same again.
Do I need to rename the files? How do I build the project and not the isolated file. I just tried to build workspace and get the same undefined reference. What software do you use?