I've been beating my head against this for too long now, and have researched everything I cannot find what's wrong.
I'm writing a GUI program in QT and have a few functions in some files external to the main program file, but within the project. The structure is something like this:
Source files:
main.cpp
mainwindow.cpp
signal.cpp
signalparse.cpp
header files:
mainwindow.h
signal.h
signalparse.h
Signal is an object that stores some data. Signalparse uses signal, parses a text file and reads it into signal. I tested this functionality on a barebones console application before putting it into my GUI program so I know it works(worked).
Now I find myself trying to call a function ReturnSignal from my SignalParse.cpp file inside my mainwindow.cpp file.
SignalParse.h is below:
#include<vector>
#include <iostream>
#include "signal.h"
void ParseLine(std::string*);
std::string ReturnTitle();
std::vector<Signal> ReturnSignal(std::string);
Showing I have declared ReturnSignal.
Inside SignalParse.cpp the function is defined as:
vector<Signal> ReturnSignal(string filename)
{
//does stuff
}
Inside mainwindow.cpp I declare an
std::vector<Signal> signalList;
to store the returned vector from ReturnSignal.
I then use
signalList = ReturnSignal(signalFilePath);
inside mainwindow.cpp to finally call this function and return my data. When commented out, there are no errors. However, this line causes the error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "class std::vector<class Signal,class std::allocator<class Signal> > __cdecl ReturnSignal(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?ReturnSignal@@YA?AV?$vector@VSignal@@V?$allocator@VSignal@@@std@@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) referenced in function "private: void __cdecl MainWindow::on_file_open_triggered(void)" (?on_file_open_triggered@MainWindow@@AEAAXXZ)
I cannot for the life of me figure out why this wont work. Does anyone have any ideas? I've been looking for hours now! I would love to re-write the question to be more generally applicable if i find a solution, but at the moment I'm completely stumped. Thanks a lot.
EDIT: Compiler being used is Microsoft Visual C++ Compiler 12.0