I have tried to simplify my situation as much as possible. I have two separate classes in two folders.
/RedRocket/model/dbhandler.h and
/RedRocket/textui/screen.h
When I make a connection between these two run a method, Im getting the following errors.
/home/ktdilsiz/projectworking1/trunk/RedRocket/textUI/screen.cpp:25: error: undefined reference to `DBHandler::test()'
:-1: error: collect2: ld returned 1 exit status
I simply want the connection to work so that I could use my methods. Here is the code that I think is relevant.
screen.h
#ifndef SCREEN_H
#define SCREEN_H
#include "../model/dbhandler.h"
#include "ncurses.h"
#include <string>
#include <vector>
//Parent class for any of the text screens.
class Screen
{
public:
void test();
};
#endif // SCREEN_H
screen.cpp file:
#include "screen.h"
void test(){
DBHandler *db;
db->test();
}
Next is dbHandler.h
#ifndef DBHANDLER_H
#define DBHANDLER_H
#include <algorithm>
#include <sqlite3.h>
#include <vector>
#include <cstring>
#include "log.h"
/* Class to handle interaction with the local test database in the /db_tools directory. Run ./newDB.sh in that directory prior to use. */
class DBHandler {
public:
void test();
}
#endif // DBHANDLER_H
dbhandler.cpp
#include "dbhandler.h"
void DBHandler::test(){
}
I tried to read about "collect2: ld returned 1 exit status" error but there are multiple different answers and it didnt resolve the situation. Also, if I add:
#include "../model/dbhandler.cpp"
to the screen.h header file, I get multiple definitions error. I can give more information about this case if you think that I should be focused on solving that error.
If I'm missing anything that could be important, please let me know.
edit1:
It was marked as a duplicate and I did read the given link, and I will read it again now but I could not figure out the problem.