I want to write a dll for an api of a device. since i am new to dlls i wanted to implement it on a simple text editor and then make one for the api.
I have made header file and cpp file but when i run the code i get error lnk2001 followed by lnk1120 which is unresolved external error.
I really have no idea where did i make a mistake, as far as i see i did it the right way. i was wondering if you guys could help me out. tnx.
here is my header file
// EditFuncsDll.h
#include <cstdio>
#include <vector>
#include <string>
namespace EditFuncs
{
class MyEditFuncs
{
private:
static std::vector<std::string> MyTextBox;
public:
static __declspec(dllexport) void Load(std::string command);
static __declspec(dllexport) void Save(std::string command);
static __declspec(dllexport) int Lines();
static __declspec(dllexport) void Add(std::string command);
static __declspec(dllexport) void Remove(std::string command);
static __declspec(dllexport) void Insert(std::string command);
static __declspec(dllexport) int wc(std::string command);
static __declspec(dllexport) void GetInfo();
};
}
and in my cpp file i just define the functions i declared in header file.
and these are the errors i get
Error 25 error LNK2001: unresolved external symbol “private: static class std::vector,class std::allocator >,class std::allocator,class std::allocator > > > EditFuncs::MyEditFuncs::MyTextBox” (?MyTextBox@MyEditFuncs@EditFuncs@@0V?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A) C:\Users\Lucy\Desktop\Erfan\Text_Editor_DLL\Text_Editor_DLL\EditFuncsDll.obj Text_Editor_DLL
and
Error 26 error LNK1120: 1 unresolved externals C:\Users\Lucy\Desktop\Erfan\Text_Editor_DLL\Debug\Text_Editor_DLL.dll Text_Editor_DLL
The head of your cpp should be like this :