C++ 未找到入口点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17136315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:57:25  来源:igfitidea点击:

Entry Point Not Found

c++dll

提问by Interminable

I am encountering a weird error when attempting to run an application (which I haven't changed the code for for a while as it works okay) linking to my DLL. This DLL used to work, but I've been making changes to the DLL's code and got it to compile okay. Unfortunately, when trying to run the application...

我在尝试运行链接到我的 DLL 的应用程序时遇到一个奇怪的错误(我有一段时间没有更改代码,因为它工作正常)。这个 DLL 曾经可以工作,但我一直在对 DLL 的代码进行更改并使其编译正常。不幸的是,在尝试运行应用程序时...

---------------------------
GameTest001.exe - Entry Point Not Found
---------------------------
The procedure entry point ??0Music@@QAE@ABV0@@Z could not be located in the dynamic link library Renderer02.dll. 
---------------------------
OK   
---------------------------

I have no idea how to interpret this error. I know what changes I have made, and my code looks fine to me. I've tried Googling this and had no luck at all.

我不知道如何解释这个错误。我知道我做了什么改变,我的代码看起来很好。我试过谷歌搜索这个,但根本没有运气。

Can anyone shed any insight to this? What does this error mean?

任何人都可以对此有所了解吗?这个错误是什么意思?

采纳答案by David Heffernan

You are linking to a function that has been exported with a mangled name, and that name is ??0Music@@QAE@ABV0@@Z. The DLL that is being loaded does not export a function of that name and hence the error.

您正在链接到一个已使用错误名称导出的函数,该名称为??0Music@@QAE@ABV0@@Z. 正在加载的 DLL 不会导出该名称的函数,因此会出现错误。

The name mangling encodes the function's name, parameters and return value. So the most likely cause for the mismatch is that you have changed the name, parameters or return value of the function in one place but not the other.

名称修饰对函数的名称、参数和返回值进行编码。因此,导致不匹配的最可能原因是您在一处更改了函数的名称、参数或返回值,而在另一处未更改。

If you have changed the DLL you'll need to re-compile it to produce new .lib and .dll files. You will also have modified the .h file. Make sure that the modified versions of all three of those files are used by the program that links to the DLL.

如果您更改了 DLL,则需要重新编译它以生成新的 .lib 和 .dll 文件。您还将修改 .h 文件。确保链接到 DLL 的程序使用所有这三个文件的修改版本。

This error message is actually helpful to you because it will make sure that both sides of the interface match before you can proceed to execute the code.

此错误消息实际上对您很有帮助,因为它会确保接口的两端匹配,然后您才能继续执行代码。

Update

更新

I didn't make it clear enough in the text above. Whenever you change the interface of the DLL you must do the following:

我在上面的文字中没有说得足够清楚。每当您更改 DLL 的接口时,您必须执行以下操作:

  1. Update any .h files that are used by the application.
  2. Re-compile the DLL to produce new .lib and .dll files.
  3. Re-compile the application using the updated .lib and .h files.
  4. Distribute the new .dll file so that the updated application loads the updated DLL.
  1. 更新应用程序使用的任何 .h 文件。
  2. 重新编译 DLL 以生成新的 .lib 和 .dll 文件。
  3. 使用更新的 .lib 和 .h 文件重新编译应用程序。
  4. 分发新的 .dll 文件,以便更新的应用程序加载更新的 DLL。

回答by sraok

It seems the function Music::Music(class Music const &)is missing from your dll. ??0Music@@QAE@ABV0@@Zis the mangled name for this function. You can demangle function names using this site.

Music::Music(class Music const &)您的 dll 中似乎缺少该功能。??0Music@@QAE@ABV0@@Z是此函数的重整名称。您可以使用此站点对函数名称进行解构。

回答by Jaya Sankar

Try this in your c++ code

在你的 C++ 代码中试试这个

extern "C"
{
   inline  __declspec(dllexport)  int MyFunction()
  {
     return  63;
  }
}