I'm retrieve a list of paths stored in a json file, I'm not having trouble receiving the path but I get the error undefined reference to `objectFactory::objList[abi:cxx11]'
When i try to add the path to a static vector of the same class.
I tried changing the types of both to see if maybe it was an issue where it was looking for a variable with the same name but a different type, but alas the issue remained.
I also tried to set the vector to be another vector of the finalized list but that didn't solve the issue.
objectFactory.h:
#ifndef PROJECT2DTD_OBJECTFACTORY_H
#define PROJECT2DTD_OBJECTFACTORY_H
#include <vector>
#include <string>
#include <fstream>
#include <nlohmann/json.hpp>
class objectFactory {
public:
static void genObjList();
private:
static std::vector<std::string> objList;
};
#endif //PROJECT2DTD_OBJECTFACTORY_H
objectFactory.cpp
#include <iostream>
#include "objectFactory.h"
using json = nlohmann::json;
void objectFactory::genObjList() {
auto file = json::parse(std::fstream("assets/objects/objectList.json"))["objects"];//[0]["path"]
for(auto i = 0; i != file.size(); ++i) {
auto path = file[i]["path"].get<std::string>();
objList.emplace_back(path);
}
}
Does anyone know what I might be doing wrong?