错误:全局范围没有 GetUrl
我的 C++ DLL 有一个新问题...我尝试导出整个类而不是仅导出一种方法。但程序现在不想编译,因为全局范围没有 GetUrl
这是我的“UrlConnector.h”: <代码>
#define ConnectMe __declspec( dllexport )
命名空间 ConnectHttps
{
连接我类
{
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;
命名空间 ConnectHttps
{
void ConnectMe::GetUrl(char* url, 无符号 bufferLength)
{
MyConnectionClass initSec;
字符串响应 = 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!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非我弄错了,否则你似乎没有给你的班级命名。
你使 ConnectMe 不是一个类名,而是一个宏来导出你的类,但你的类应该有一个名称
也许可以尝试
此外,我也不能 100% 确定这一点,因为我目前无法访问编译器,但输入:
您的 .cpp 文件中的内容不正确。相反,你应该:
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: