Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined symbols for architecture x86_64 using C++ classes

Tags:

c++

object

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;
}
like image 703
herteladrian Avatar asked Sep 03 '25 16:09

herteladrian


1 Answers

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

like image 115
Syntactic Fructose Avatar answered Sep 05 '25 05:09

Syntactic Fructose