Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a VS 2010 solution with two C++ projects. One produces an application (.exe). The other produces a static library (.lib). The application uses the static library. The solution builds and the application executes as expected. The class is declared as follows.

class MyClass
{
public:
static void MyFunc(void);
};

if the class declaration is changed as follows:

class __declspec(dllexport) MyClass
{
public:
static void MyFunc(void);
};

The application (.exe) build fails with the following error message.

.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static

Why ?

What I have tried:

searched the web and did not find an explanation
Posted
Updated 20-Jan-18 0:11am
v3

1 solution

You are creating a static library, not a dll, so you do not use __declspec(dllexport). You just need to ensure that your project build is set for a static library, and that your application includes the .lib file that this project produces.
 
Share this answer
 
Comments
CPallini 20-Jan-18 6:16am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900