Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C2375: redefinition; different linkage

Error place in api:

#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT int CAnyseeUSBTVControllerDlg::InitCaptureDevice()
{

In my .h library class and function definition:

class CAnyseeUSBTVControllerDlg : public CDialog
{
// Construction
public:
    int InitCaptureDevice(void);

Any idea how to resolve it?

"Error 1 error C2375: 'CAnyseeUSBTVControllerDlg::InitCaptureDevice' : redefinition; different linkage c:\Program Files\toATS_DVS\anysee\anyseee30\anyseee30\anyseeUSBTVControllerDlg.cpp 122 anyseee30"

like image 643
CarolusPl Avatar asked Sep 09 '10 13:09

CarolusPl


2 Answers

You have to make sure you use the same declaration in your header file. Otherwise it is seen as different methods.

class CAnyseeUSBTVControllerDlg : public CDialog
{
// Construction
public:
    int InitCaptureDevice(void);
    DLLEXPORT int CaptureDevice(void);

See Using dllimport and dllexport in C++ Classes

like image 186
Rod Avatar answered Oct 01 '22 19:10

Rod


This may happen because

  1. You defined the prototype of a function in different places with different visibility (extern vs static)
  2. Same as above but different name mangling (extern "C" vs extern "C++")
  3. Same as above but different dll export (__declspec(dllimport) vs __declspec(dllexport)).

To solve, enable /p for files to see how they are preprocessed (this has to be in a file by file basis, and will stop generating .obj for that file), look for a .i file with the result.

Or using /displayincludes, or simply greping thru the code.

like image 24
Fernando Gonzalez Sanchez Avatar answered Oct 01 '22 19:10

Fernando Gonzalez Sanchez