I have a very simple c++ dll that adds two numbers. The source file looks like:
extern "C" {
__declspec(dllexport) double __stdcall myadder(double a,double a)
{
return (a+b);
}
}
with a def file:
LIBRARY myadder
EXPORTS
_myadder@16
The code of the exe is:
#include "stdio.h"
__ declspec(dllimport) double myadder(double a, double b);
int main()
{
double r;
r=myadder(5,6);
printf("myadder = %f \n",r);
return 0;
}
and I tell it to use myadder.lib qualified with the path to it. but I get the error:
1>helloworld.obj : error LNK2019: unresolved external symbol __imp__myadder referenced in function _main
1>C:\lotus\optfunc\helloworld\Debug\helloworld.exe : fatal error LNK1120: 1 unresolved externals
and if I get rid of the __declspec(dllimport) I instead get:
1>helloworld.obj : error LNK2019: unresolved external symbol _myadder referenced in function _main
What am I doing wrong?