4

I've read the other questions on this topic but still haven't figured out how to fix my issue

Thank you in advance for your help!

My error is:

Undefined symbols for architecture x86_64: "Record::Record(std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >, double*)", referenced from: _main in akh70P3ClassTester-946637.o ld: symbol(s) not found for architecture x86_64

Record.h

#include <string>
#include <vector>

using namespace std;

class Record
{
public:
    Record();
    Record(vector<string> , double []);

private:
    //some variables
};

Record.cpp

#include "Record.h"
#include <string>
#include <vector>

using namespace std;

Record::Record() {}

Record::Record(vector<string> inputs, double num_inputs[] )
{
    //variables happens
}

Main.cpp

#include "Record.h"
#include <vector>

using namespace std;

int main() {

    vector<string> inputs;

    double num_inputs[] = {};

    Record temp(inputs, num_inputs);

    return 0;
}
Willeke
  • 14,578
  • 4
  • 19
  • 47
herteladrian
  • 381
  • 1
  • 6
  • 18
  • how are you compiling this program? please include your makefile if you have one – Syntactic Fructose Nov 02 '16 at 03:33
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Danh Nov 02 '16 at 03:33
  • I saw the tag for objective-c, is this being compiled via Xcode? – NonCreature0714 Nov 02 '16 at 03:36
  • @NonCreature0714 I compiled it using SublimeText2 which is telling me it used this shell command: g++ "main.cpp" -o "main" && "main" (i omitted the full file path) so I think Syntactic Fructose's answer is right, because it isn't compiling report.cpp. I am testing it right now – herteladrian Nov 02 '16 at 03:39

1 Answers1

9

You probably aren't including Report.cpp in your compilation, e.g. only doing g++ main.cpp -o main

Instead, compile your program by including the report files: g++ main.cpp report.cpp -o main

Syntactic Fructose
  • 18,936
  • 23
  • 91
  • 177
  • 1
    You were right. I wasn't using a makefile because I didn't know what that is until googling just now after your question. I was using SublimeText2's single file C++ build and run function( via Cmd-B). compiling via Terminal with the line you gave me worked and it makes sense. Thanks! – herteladrian Nov 02 '16 at 03:46