[英]Unable to find an entry point named '' in DLL 'cvextern'
[英]"Unable to find an entry point named 'connect2' in DLL "xy"
我知道还有很多其他类似的问题,但没有人帮助我。 因此,我正在为 c++ 中的 mysql 连接编写 dll 以便稍后在 ZD7EFA19FBE7D2372FD5ADB6024 中使用它但它告诉我它找不到我的方法的入口点。
有任何想法吗?
这是我的 C++ 代码:
Sweepape.h
#ifdef SWEEPAPE_EXPORTS
#define SWEEPAPE_API __declspec(dllexport)
#else
#define SWEEPAPE_API __declspec(dllimport)
#endif
extern "C" {
//// Diese Klasse wird aus der DLL exportiert.
//class SWEEPAPE_API CSweepape {
//public:
// CSweepape(void);
// // TODO: Methoden hier hinzufügen.
//};
//
//extern SWEEPAPE_API int nSweepape;
//extern SWEEPAPE_API int nYear;
//
//SWEEPAPE_API int fnSweepape(void);
SWEEPAPE_API int connect2(int a);
}
Sweepape.cpp
#include "Sweepape.h"
SWEEPAPE_API int connect2(int a)
{
std::cout << "Connecting" << a;
return 0;
}
C#
using System;
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
class Program
{
private const string path = @"C:\Users\chris\source\repos\Sweepape\Debug\Sweepape.dll";
[DllImport(path, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern int connect2(int a);
static void Main(string[] args)
{
connect2(2);
}
}
}
您在这里并没有真正给我们太多帮助,因此最可能的原因可能是:
您的 C++ 库是 32 位的,而您的 C# 应用程序是 64 位的,因为这些是默认值。 你需要两者都是相同的“位”。
那条硬编码的路径是一个尖叫的危险信号。 正确设置您的环境,没有人会这样使用您的代码。 包括你,你可以清楚地看到。
根据您的编译器和设置,您在调用约定方面撒谎。 由于您没有在 C++ 代码中明确编写调用约定,并且没有显示任何有用的信息(例如您实际编译该代码的方式),因此很难说。
这里不太可能成为问题,但您绝对是在撒谎您的 C++ 字符集。 那里没有 unicode 代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.