本文介绍了DLL从其父进程(Loader)获取符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将程序移植到MS Windows。该程序使用动态加载的插件。插件在主程序中引用符号。我甚至不能将DLL通过链接器,而不会解析所有符号。有没有办法解决这个问题?

解决方案

(抱歉,我想在评论中要求澄清,太多的新手可以被允许。)



当您说插件主程序中的引用符号时,是关于引用函数还是数据?另外,你使用什么语言/编译器?



假设它只是关于函数,并且在C / C ++中:可以从.EXE导出一个函数,就好像是一个DLL。只需在.EXE中的函数定义前面指定__declspec(dllexport)。在编译.EXE时,应该生成一个.LIB文件,然后在链接每个插件时将其用作输入。


I am porting a program to MS Windows. This program uses dynamically loaded plugins. The plugins reference symbols in the main program. I cannot even get the DLLs past the linker without all symbols being resolved. Is there a way to solve this?

解决方案

(Sorry, I'd like to ask for clarification in a comment but I'm too much of a newbie to be allowed.)

When you say the plugins "reference symbols in the main program", is it about referencing functions or data? Also, what language/compiler are you using?

Assuming it's only about functions, and in C/C++: it's possible to export a function from a .EXE as if it were a DLL. Just specify __declspec(dllexport) in front of the function definition in the .EXE . When compiling the .EXE, a .LIB file should get generated, which you can then use as input when linking each plugin.

这篇关于DLL从其父进程(Loader)获取符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:59