Reputation: 780
Whenever I start to build my dll I get this error: fatal error LNK1169: one or more multiply defined symbols found
I think there's nothing wrong with the code because I copied it from a source:
ExoDll1.cpp
#include "stdafx.h"
double BoxArea(double L, double H, double W);
double BoxVolume(double L, double H, double W);
extern "C" __declspec(dllexport)void BoxProperties(double Length, double Height,
double Width, double& Area, double& Volume);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
double BoxArea(double L, double H, double W)
{
return 2 * ((L*H) + (L*W) + (H*W));
}
double BoxVolume(double L, double H, double W)
{
return L * H * W;
}
void BoxProperties(double L, double H, double W, double& A, double& V)
{
A = BoxArea(L, H, W);
V = BoxVolume(L, H, W);
}
I tried to create a new project and delete the old ones but same problem still exists.. What seems to be the problem?
Upvotes: 0
Views: 2755
Reputation: 45444
This error comes not from the compiler, but from the linker. This means that the compiler found nothing wrong, in particular, no duplicate definitions of symbols in any one compilation unit. However, the linker, which generates the .dll library, loads several compilation units and found duplicate definitions of symbols across compilation units.
This happens if several compilation units contain the same code with external linkage, i.e. if you #include
d a source code, or if in a header file (which more than one compilation unit #include
s) a function was defined and not declared inline
.
Upvotes: 1
Reputation: 13529
This error message cannot appear with only a single translation unit (such as ExoDll1.cpp
). You might be, for example, unknowingly trying to compile multiple versions of this code simultaneously.
Examine your project and get rid of any source code that you do not want to compile.
Make sure that you do not have #include "ExoDll1.cpp"
anywhere in your project.
Upvotes: 2