JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.92k stars 5.49k forks source link

Julia cannot find a dll #11066

Closed easleykg closed 9 years ago

easleykg commented 9 years ago

I can use "User32.dll". find_library(["User32"]) returns "User32".

However, working backward from an attempt to call "whatever.dll" to just trying to find_library(["whatever.dll"]), nothing I have tried (and I've tried A LOT) returns anything useful.

I have investigated paths, put my dll in the same directory with User32 (how can it not find it THERE!?!), put my dll in the same folder with julia.exe, added where my dll is to LOAD_PATH and DL_LOAD_PATH. Somewhere, somehow, something got skipped.

I so strongly suspect it is the most simple thing in the world, but I'm tired of bleeding on it. Please help. Thank you.

ihnorton commented 9 years ago

There is probably a loading error. Try to dlopen("/path/to/my.dll") directly and see if you get an error. Or check it in dependency walker.

On Thu, Apr 30, 2015 at 11:53 AM, easleykg notifications@github.com wrote:

I can use "User32.dll". find_library(["User32"]) returns "User32".

However, working backward from an attempt to call "whatever.dll" to just trying to find_library(["whatever.dll"]), nothing I have tried (and I've tried A LOT) returns anything useful.

I have investigated paths, put my dll in the same directory with User32 (how can it not find it THERE!?!), put my dll in the same folder with julia.exe, added where my dll is to LOAD_PATH and DL_LOAD_PATH. Somewhere, somehow, something got skipped.

I so strongly suspect it is the most simple thing in the world, but I'm tired of bleeding on it. Please help. Thank you.

— Reply to this email directly or view it on GitHub https://github.com/JuliaLang/julia/issues/11066.

easleykg commented 9 years ago

Thank you for your quick response. Been there, done that, but did try again on your say so.

I failed to mention that I am in Windows 7. I guess User32, and "dll" imply that.

I take find_library to be the simplest test -- if it can't find it, how can it open it?

Is there a path where there should be no way Julia wouldn't find it there?

pao commented 9 years ago

Have you checked that all the DLLs dependencies resolve with Dependency Walker? The error from the OS is misleading, in that it might be referring not to finding the DLL itself but to one of the DLLs it loads in turn.

ihnorton commented 9 years ago

find_library uses dlopen internally, so if you can't do the latter then the former won't work either. do you get an error message, or a usable handle, when dlopen'ing directly?

On Thu, Apr 30, 2015 at 12:53 PM, pao notifications@github.com wrote:

Have you checked that all the DLLs dependencies resolve with Dependency Walker? The error from the OS is misleading, in that it might be referring not to finding the DLL itself but to one of the DLLs it loads in turn.

— Reply to this email directly or view it on GitHub https://github.com/JuliaLang/julia/issues/11066#issuecomment-97878190.

easleykg commented 9 years ago

OK. I can use this DLL from Excel VBA. I also have a college who unfortunately only had time to tell me "it works from my machine" (meaning accessing it using Julia) before he became unavailable for a few days. So, I know this DLL can be used.

Dependency Walker does provide interesting info, however: Error: Modules with different CPU types were found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

The module is SYSNTFY.DLL, and CPU for it is listed as AMD64. My machine is Intell 64-bit. I'm trying not to introduce too much clutter, but the DLL I have (from an outside source) has an "x64" and an "x86" version. The "x64" appears to be for AMD64 processors, and WILL NOT work in Excel. It is the "x86" version I am trying to use with Julia, though I have spent considerable time trying the x64 as well.

My best guess of what's going on is that "VBA" doesn't worry about modules is doesn't use, while Julia is particular about "the whole thing being right".

tkelman commented 9 years ago

You can only load 32 bit dll's from 32 bit Julia, and only 64 bit dll's from 64 bit Julia. That's what the Dependency Walker Error is talking about. Find which dll it's showing as red and see if you can resolve the inconsistency.

easleykg commented 9 years ago

I have uninstalled 64-bit Julia and installed 32-bit Julia, and tried that way (I now have it switched back). I probably didn't try everything in 32-bit, but what was expected to work "out of the box" didn't.

I have no control over the DLL; it isn't mine. The different CPU is just something I'm stuck with -- but it doesn't stop VBA from using it.

It sounds like uninstalling 64-bit Julia and installing 32-bit is the next most reasonable path? I am surprised Julia doesn't "fall back" for a 32-bit DLL. I rarely get involved at this level.

tkelman commented 9 years ago

You didn't specify which dll's dependency walker was complaining about the different cpu types. You might have a mix of versions of dependencies polluting your path and getting found. It's hard for us to tell without more information.

tkelman commented 9 years ago

You can also save yourself a bit of time, there's nothing wrong with having multiple versions (32 vs 64 bit, different releases, etc) of Julia installed on the same machine, as long as you install them to separate destinations and don't try to put both of them on the path at the same time.

pao commented 9 years ago

:heart: Dependency Walker

I don't believe this is a Julia bug, so I will close this, but feel free to continue discussion.