ocaml / flexdll

a dlopen-like API for Windows
Other
97 stars 30 forks source link

Compile ERROR with MSVC VS2019 #130

Closed zkccpro closed 4 months ago

zkccpro commented 5 months ago

I got 2 unresolved symbols during linking with MSVC VS2019: static_symtable reloctbl

I find that the two symbols are both extern declared in .c file but no any reference. So, I change them to static declare and it can pass compiling and linking with my project. However, when I try to load a DLL in windows, flexdll cannot fetch any symbols in my DLL, flexdll_dlsym API return NULL. I try dumpbin.exe tool in widnows, and it truely got correct symbols.

Now, I begin getting confused, HOW can I use flexdll in my VS2019 project?

nojb commented 5 months ago

Generally speaking, you must use flexlink as your linker in order to use the FlexDLL "dlsym" API. Flexlink will take care of defininig the needed symbols at linktime. There is a simple example in the README of the repository.

dra27 commented 4 months ago

I'm not sure that it's possible to use flexlink strictly in a VS2019 project - i.e. from within Visual Studio, because while Visual Studio allows you to pass arbitrary additional options to both the compiler and the linker, I don't think it gives anyway to complete replace the linker. Both the README (as @nojb notes) and the files in test/ show how to compile a pure C program using FlexDLL manually - it's possible that that can be set-up as a completely custom project in Visual Studio (so most of your code in a separate normal C project producing a .lib and then linked with flexlink in a completely manual project).

dra27 commented 4 months ago

I'm going to close this only inasmuch as I don't think there's anything which needs changing in FlexDLL itself