Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I receive error LNK1561 "Entry point must be defined" when I compile a DLL Project?

I try to compile a very simple dynamic library project as .dll file. The name of the project is "Library". I'm using Visual Studio 2015 and the project properties are these:

Debug Properties

Release Properties

In the project there are two files only: ClassA.h and ClassA.cpp.

The code in ClassA.h is:

#ifndef CLASSA_H
#define CLASSA_H

using namespace std;

#ifdef LIBRARY_EXPORTS
#define CLASSA_API __declspec(dllexport) 
#else
#define CLASSA_API __declspec(dllimport) 
#endif

class ClassA
{
public:
    static CLASSA_API void func();
};


#endif

The code in ClassA.cpp is:

#include "ClassA.h"
#include <iostream>


void ClassA::func()
{
    cout << "SUCCESS!" << endl;
}

When I try to compile this project I receive this error:

Severity Code Description Project File Line Error LNK1561 entry point must be defined Library C:\Users\UX303\Documents\Visual Studio 2015\DLLTest\Library\LINK 1

like image 390
Radioga Avatar asked May 30 '16 15:05

Radioga


2 Answers

It is likely that your configuration is not right.

Be sure to double check your "Active Configuration" (Debug / Release), to see if you are really building a DLL.

I have just made such a mistake, and came across this question.

like image 92
sanbrother Avatar answered Sep 24 '22 19:09

sanbrother


In 64 bit machine I was getting same error when 'Solution Platforms' set to 'x86'. The error goes away when I set the 'Solution Platforms' to 'x64'.

like image 20
Pabitra Dash Avatar answered Sep 22 '22 19:09

Pabitra Dash