I have a new problem with my C++ DLL… I have tried exporting the entire class instead of only one method. But the program doesn’t want to compile now because of that the global scope has no GetUrl
Here is my “UrlConnector.h”:
#define ConnectMe __declspec( dllexport )namespace ConnectHttps { class ConnectMe { void GetUrl(char *url, unsigned int bufferLength); }; }
and here is the part of my UrlConnector.cpp that isn’t compiling:
#include "UrlConnector.h" #include "MyConnectionClass.h" #include using namespace std;namespace ConnectHttps { void ConnectMe::GetUrl(char* url, unsigned bufferLength) { MyConnectionClass initSec; string response = initSec.GetResult(); strncpy_s(url, bufferLength, response.c_str(), response.length()); } }
Now, I would like to be able to create an DLL from this, and I would like to make a test program to call the class and the method GetUrl from a dll. I’m using Visual Studio 2010 with Visual C++ DLL.
I’ve also managed to read this from the MSDN and this tutorial as well, but I just can’t seem to get it to work!
I would really appreciate any help!
Unless I’m mistaken, you don’t seem to be giving your class a name.
You made ConnectMe not a class name but a macro to export your class, but your class should have a name
Maybe try
Also I’m not 100% sure of this because I don’t have access to a compiler at the moment, but typing:
In your .cpp file isn’t correct. Instead you should have: