Search code examples
.netf#llvmdllimportllvm-fs

DllImport can't find dll even though dll is in same folder as executable


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.


Solution

  • 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.