13

I'm trying to use the llvm-fs project, which provides llvm bindings for F#. I have compiled the LLVM-3.1.dll file with --enable-shared and it now resides in same directory as my compiled executable (I checked with Environment.CurrentDirectory). The DllImport in llvm-fs looks like:

[<DllImport(
    "LLVM-3.1.dll",
    EntryPoint="LLVMModuleCreateWithName",
    CallingConvention=CallingConvention.Cdecl,
    CharSet=CharSet.Ansi)>]
extern void* (* LLVMModuleRef *) moduleCreateWithNameNative(string ModuleID)

Yet when I run my application it errors with:

Unable to load DLL 'LLVM-3.1.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)

How do I get the DLL to be loaded? For reference, here's the exact DLL I'm trying to load.

Callum Rogers
  • 15,630
  • 17
  • 67
  • 90

2 Answers2

22

This:

"The specified module could not be found"

can point to some library, which LLVM-3.1.dll depends from, not the LLVM-3.1.dll itself.

Dennis
  • 37,026
  • 10
  • 82
  • 150
  • just saved me hours – Anatoly Vasilyev Mar 21 '18 at 16:07
  • If you have the source code of the dll (in general case) make sure you compile it with `/MT` instead of `/MD` (`/MTd` instead of `/MDd` in case of debug build). This will use static linking of runtime libraries. https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019 – Nenad Jan 09 '20 at 11:54
  • Any hint how to pinpoint that some library ? Dependency Walker just freezes ( – Dfr Nov 17 '21 at 17:04
12

When DLL or EXE fail to load as in this case Depends.exe is very handy - it display the complete EXE/DLL dependency tree, highlighting what cannot be loaded or it is missing.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
MiMo
  • 11,793
  • 1
  • 33
  • 48