Reputation: 505
I am trying to get this to compile, but every time I go to compile main.cpp I get the same error:
Undefined symbols for architecture x86_64:
"tlogic::tlogic()", referenced from:
_main in ccAcayG4.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I tried debugging it for a while, but the error seems to persist. Any help would be appreciated.
Here is main.cpp:
#include <iostream>
using namespace std;
#include "tlogic.h"
int main()
{
tlogic test;
exit(EXIT_SUCCESS);
}
tlogic.h:
#ifndef TLOGIC_H
#define TLOGIC_H
class tlogic {
public:
tlogic();
tlogic(bool);
~tlogic();
void init();
void get_command();
private:
bool debug;
};
#endif
And finally, tlogic.cpp:
#include <iostream>
using namespace std;
#include "tlogic.h"
tlogic::tlogic()
{
cout << "Testing" << endl;
debug = false;
}
tlogic::tlogic(bool debug_)
{
cout << "Testing 2" << endl;
debug = debug_;
}
tlogic::~tlogic()
{
}
void tlogic::game_init()
{
}
void tlogic::get_command()
{
}
Thank you for the help.
EDIT: Fixed tlogic::glogic, etc.
Upvotes: 0
Views: 3471
Reputation: 791341
You need:
g++ -o prog main.cpp tlogic.cpp
When you are compiling and linking in a single step you need to make sure that you pass all of the source files required to make your complete program to the compiler.
Upvotes: 2