I've been going through the dll walkthrough on MSDN and it works fine. I then removed all the C++ style code in the dll and replaced it with the C equivalent, and it still works.
BUT, when I rename the file from X.cpp to X.c (which I guess causes compilation in C-mode), I get error LNK2019 (unresolved external symbol) for every function in the dll. For my purposes it's essential that the dll be in C not C++ because that's what Java Native Access supports.
Here's the header of the dll:
__declspec(dllexport) double Add(double a, double b);
__declspec(dllexport) double Subtract(double a, double b);
__declspec(dllexport) double Multiply(double a, double b);
__declspec(dllexport) double Divide(double a, double b);
Here's the body of the (C++) testing program that uses the dll:
#include <iostream>
#include "MyMathFuncs.h"
using namespace std;
int main()
{
double a = 7.4;
int b = 99;
cout << "a + b = " <<
Add(a, b) << endl;
cout << "a - b = " <<
Subtract(a, b) << endl;
cout << "a * b = " <<
Multiply(a, b) << endl;
cout << "a / b = " <<
Divide(a, b) << endl;
return 0;
}
(Just to clarify it's fine that the testing program is in C++; it's only the dll I'm trying to compile in C).