-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate import library for exported function of the main executable file #104
Comments
Thanks for posting your experience with this! I have two questions with it, which I haven't looked into the detail. IIRC, generating .def files for the executable is brittle in that the executable can't be renamed - is that still the case? The other issue is data symbols (which we use for OCaml) - does this still only work for functions? |
You mean if a dll is linked to an exe, for example. My guess is this is correct, but I haven't tried it.
I haven't tried it, so I can't say whether some data symbol(for example, the global variable) can be shared, I will tried it. |
The renaming part is the "killer" requirement (albeit subtly) for how FlexDLL is used in OCaml. In this case, we need DLLs which can be loaded by any executable (via The Windows loader expects all the symbols in the DLL being loaded to be resolved by import libraries specified in the DLL only - FlexDLL extends that to allow the symbols to come directly from what's already running with the need to specify the import libraries (which makes the behaviour closer to |
I have just tested it, and I can change the exe file name, and when I run the exe file, the dll file can still be loaded correctly, and it can call the function inside the exe. This means the "rename" feature is OK in my method. |
I have just tested it. I can correctly export a global variable from the exe, and the dll can access the global variable. So, I think the exported feature from exe file works correctly for both functions and variables. |
There is a statement in your project home page:
While, it looks like I can do this with the tool
gendef
anddlltool
.The method I was using is like:
For example, the
exe_export.exe
has some code like:The content of the
interface_exe.h
is like below:And I have another
dll.cpp
file which is used to generate the dll.I first build the
exe_export.exe
file, and later I use the commands below to generate the import.a
file:Then later, I link the
libexe_export.a
file to generate the dll.Now, when I run the exe file, I have two methods to call the methods in the dll.
One is using the
GetProcAddress
method.The other is using the imported method, which I can directly call
All works fine.
Here are some reference:
1, the method I use is described as the .def and .a method, see this discussion:
Enhanced DLL / Discussion / Help and FAQ: The .def and .a method mentioned in the home page
2, https://www.codeproject.com/Articles/17697/Plugin-System-an-alternative-to-GetProcAddress-and
The method mentioned in this link is using MSVC, and I think it is similar with the gendef and dlltool method.
3, my demo code was changed from the sample code in this discussion:
Exporting symbols in a .exe for external DLLs
Hope the above method can help others.
The text was updated successfully, but these errors were encountered: