Q
Q
Quark2021-09-17 15:36:29
C++ / C#
Quark, 2021-09-17 15:36:29

Why am I getting "unresolved external symbol"?

My DLL class needs to have static variables. However, when I try to use them, I get the LNK2001 error.

Here is part of my code:

.h

extern "C" GRAPHICLIBRARY_API int SizeX;

extern "C" GRAPHICLIBRARY_API int SizeY;

extern "C" GRAPHICLIBRARY_API vector<string> Screen;


.cpp
static class ScreenClass {
public:
    __declspec(dllexport) static int SizeX;
public:
    __declspec(dllexport) static int SizeY;

public:
    __declspec(dllexport) static vector<string> Screen;

public:
    __declspec(dllexport) static bool InitializeScreen(int sizeX,int sizeY) {

//Ошибка ссылается на строки ниже:

        ScreenClass::SizeX = sizeX; 
        ScreenClass::SizeY = sizeY; 

        ScreenClass::Screen.clear(); 
//.......
       }
}


Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-09-17
@jcmvbkbc

extern "C" GRAPHICLIBRARY_API int SizeX;
extern "C" GRAPHICLIBRARY_API int SizeY;
//Error refers to the lines below:
ScreenClass::SizeX = sizeX;
ScreenClass::SizeY = sizeY;

Do you see the register difference?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question