为什么不能“无法在 dll 中找到程序入口点”?当我确定把它放进去的时候?

发布于 2024-08-13 13:10:55 字数 911 浏览 4 评论 0原文

我有一个非常模糊的问题,但我希望有人可以帮助解决。我正在修改一个 C++ 项目,昨天它仍然可以工作,但今天就不行了。我很确定我没有更改任何内容,但为了完全确定我再次从 SVN 检查了该项目,我什至恢复到以前的系统还原点(因为这是一台工作计算机,它有时会秘密安装更新等)。 )。编译成功后,程序可以启动,但与它交互后,出现以下错误: 程序入口点?methodName@className@@UAEXXZ无法定位在动态链接库libName.dll中。

我在网上搜索过,但大多数人的问题似乎是由旧版本引起的正在使用的 DLL 的名称。我搜索了我的电脑,没有旧版本。如果我删除正确的版本,应用程序将无法启动。如果我重新编译该项目,则会再次创建 DLL,因此我非常确定应用程序正在使用正确的 DLL,并且编译正在创建它。如果我在错误引用的方法中引入语法错误,则该项目将拒绝编译,所以我猜这意味着它也在编译包含该方法的文件。

基本上我对 DLL、链接等一无所知,所以如果有人知道为什么项目中定义非常明确的函数突然不再进入 DLL,我将不胜感激。 。我知道这很模糊,如果需要更多信息,我很乐意提供。谢谢!

更新:我已经尝试了给定的建议,但仍然卡住了。 __declspec(dllexport) 显然在整个项目中没有使用。使用 Dependency Walker 打开 DLL 会显示右上角的空白部分,下面的部分列出了错误消息中的函数。如果我检查Undecorate C++ Functions,它看起来不错,但如果我不这样做,我会从错误消息中得到奇怪的问号和@s,并且最后似乎有一个区别:

?methodName@className@@UAEXXZ
?methodName@className@@UAEXH@Z

也许这是问题,但我不知道这意味着什么,可能是什么原因造成的,以及我能做些什么。

I have a really vague problem, but I hope someone can help with it. I was modifying a C++ project and yesterday it was still working, but today it's not. I'm pretty sure I didn't change anything, but to be completely sure I checked the project out from SVN again and I even reverted to a previous system restore point (because this is a work computer, it sometimes secretly installs updates etc.). After succesfully compiling it, the program can start up, but after I interact with it, I get this error:
The procedure entry point ?methodName@className@@UAEXXZ could not be located in the dynamic link library libName.dll.

I've searched the internet, but most people's problems seem to be caused by an older version of the DLL being used. I searched my computer and there is no older version. If I delete the correct version, the application doesn't start. If I then recompile the project, the DLL is created again, so I'm both pretty sure that the application is using the correct DLL and that the compilation is creating it. If I introduce syntax errors into the method that the error refers to, the project refuses to compile, so I guess this means that it is also compiling the files that contain the method.

Basically I don't know anything about DLL's, linking, etc. so I would greatly appreciate it if anybody has an idea as to why the functions that are very clearly defined in the project are all of a sudden not making it into the DLL anymore. I know this is vague and if any more information is required I will gladly provide it. Thanks!

Update: I have tried the given suggestions, but I'm still stuck. __declspec(dllexport) is apparently not used in the entire project. Opening the DLL with Dependency Walker shows me an empty top right section and the section below it lists the function from the error message. If I check Undecorate C++ Functions it looks fine, but if I don't I get the weird question marks and @s from the error message and there appears to be a difference at the end:

?methodName@className@@UAEXXZ
?methodName@className@@UAEXH@Z

Perhaps this is the problem, but I have no idea what it means, what may have caused this and what I can do about it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

や三分注定 2024-08-20 13:10:55

您实际上是否使用 __declspec(dllexport)?我的猜测是否定的——如果没有该声明,该函数将不会由 DLL 导出(或者换句话说,加载该 DLL 的程序将无法访问没有该声明的函数)。

另外,尝试使用 Dependency Walker 来准确查看 DLL 提供了哪些函数。


事实上 __declspec(dllexport) 不在函数声明中使用是可以的——大多数时候,它只会在单个头文件中使用一次,就像

#ifdef MAKING_DLL
#define FOO_API __declspec(dllexport)
#else
#define FOO_API
#endif

这样,如果你有 #define MAKING_DLL 在该部分之前,所有声明为 FOO_API int BakeACake() 的函数都将根据是否定义了 MAKING_DLL 来导出。项目可能期望在命令行上定义 MAKING_DLL (或其等效项),具体取决于构建的项目类型(例如 /DMAKING_DLL;或者您可能会甚至需要自己定义 FOO_API,如 /DFOO_API=__declspec(dllexport)

Dependency Walker 右上方的空白部分仅意味着您的程序未链接到 DLL 相应的 .lib 文件。只是意味着您正在使用 LoadLibrary 或 LoadLibraryEx 来访问 DLL 中的函数。

另一个相当可能的情况(基于损坏的名称不同的事实)是该程序是。使用与 2008 版本不同的 Visual Studio 构建,与普通 C 不同,C++ 没有标准的二进制接口,这意味着在构建程序和 DLL 时必须使用相同的编译器。在 DLL 中使用 C++ 类 如果可以,请尝试在 VS2008 中重建程序,或者尝试在与构建程序相同的 VS 版本中重建 DLL。

Are you actually using __declspec(dllexport)? My guess is no -- without that declaration, that function will not be exported by the DLL (or in other words, programs loading that DLL will not have access to functions without that declaration).

Also, try using Dependency Walker to see exactly which functions your DLL has made available.


The fact that __declspec(dllexport) isn't used in function declarations is okay -- most of the time, it will only be used once in a single header file, like

#ifdef MAKING_DLL
#define FOO_API __declspec(dllexport)
#else
#define FOO_API
#endif

So that if you have #define MAKING_DLL before that section, all functions that are declared like FOO_API int BakeACake() will be exported based on whether MAKING_DLL was defined. It's possible that the project was expecting MAKING_DLL (or its equivalent) to be defined on the command line, depending on the project type built (something like /DMAKING_DLL; or you might even need to define FOO_API yourself like /DFOO_API=__declspec(dllexport).

The empty top right section in Dependency Walker just means your program isn't linking against the DLL's corresponding .lib file. That's okay, it just means you are using LoadLibrary or LoadLibraryEx to access functions in the DLL.

Another fairly likely scenario (based on the fact that the mangled names are different) is that the program was built using a different version of Visual Studio than 2008, which you used to build the DLL. Unlike plain C, there's no standard binary interface for C++, which means that you have to use the same compiler to build the program and the DLL when you are using C++ classes in the DLL. If you can, try rebuilding the program in VS2008, or try rebuilding the DLL in the same version of VS as the program was built.

青春如此纠结 2024-08-20 13:10:55

下载 dependency walker 并使用此工具打开您的 dll。它将显示从 dll 导出的函数列表。检查上述方法是否是预期功能的一部分。如果不是,则意味着您不小心删除了该 dll 中某个类的 __declspec(dllexport)。

Download dependency walker and open your dll using this tool. It will show a list of exported functions from your dll. Check whether the above said method is part of the expected functions. If it's not, then it means you accidentally removed __declspec(dllexport) for one of the classes in that dll.

机场等船 2024-08-20 13:10:55

我觉得有点傻,但我找到了答案。我使用的应用程序(exe)显然加载了第二个不同的 dll,它依赖于我原来的帖子中提到的那个。第二个 dll 仍然需要旧函数,并且还需要针对更新的 dll 重新编译。

非常感谢在这里试图帮助我的人们!

I feel a bit stupid, but I found the answer. The application (exe) I was using apparently loaded a second, different dll which had a dependency on the one mentioned in my original post. This second dll was still expecting the old functions and also needed to be recompiled against the updated dll.

Many thanks to the people who tried to help me here!

百合的盛世恋 2024-08-20 13:10:55

使用上面帖子的信息,我找到了简单的通用解决方案。您所需要做的就是使用 dependency walker 打开可执行程序,查找缺少的函数,查看哪些 dll 使用它,找到构建该 dll 的项目并重建它。

Using information of the posts above I found simple general solution. All you need to do is open programs executable with dependency walker, look for the missing functions, look what dll's are using it, find the project which builds that dll and rebuild it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文