Muxelmann / OpenDSSDirect.make

A set of scripts to download and compile the up to date version of OpenDSS library.
Other
10 stars 4 forks source link

First lib release (for macOS and Linux) #10

Closed Muxelmann closed 7 years ago

tshort commented 7 years ago

Awesome! I'll give it a try.

Muxelmann commented 7 years ago

Let me know how it goes.

tshort commented 7 years ago

It failed on MacOS:

https://travis-ci.org/tshort/OpenDSSDirect.jl/jobs/259339483#L93

I don't have a way to test this locally, and using Travis to try to debug is tough.

I haven't tried Linux, yet. I'm sure that'll work. My only question there is whether it'll work on my cluster which is an older version of Red Hat.

tshort commented 7 years ago

Along those lines, for macOS, is there a way that klusolve can be compiled into libopendssdirect, like it is on Linux? Any reason there for the difference?

Muxelmann commented 7 years ago

I had a long attempt at statically linking the libraries in macOS. However, that doesn't seem to be supported by Apple (link). This means, we have two options of using them:

  1. Either we reference dynamic libraries against each other; this is done by e.g. copying libklusolve.dylib into e.g. /usr/local/bin,
  2. or we load them into memory in a correct order and make sure they use @rpath or @executable_path to find each other.

At least that's how I understood it for now...

Muxelmann commented 7 years ago

Also, I forgot to address your second last comment (sorry about that). Have you tried loading libklusolve.dylib before libopendssdirect.dylib? Because if I don't do this (in Python), then is the result is similar to yours:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    ctypes.CDLL('_lib/x86_64-darwin/libopendssdirect.dylib')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(_lib/x86_64-darwin/libopendssdirect.dylib, 6): Library not loaded: @rpath/libklusolve.dylib
  Referenced from: /Users/maxi/Documents/git/OpenDSSDirect.make/_lib/x86_64-darwin/libopendssdirect.r1993.dylib
  Reason: image not found

Otherwise I get no prompt, i.e. it appears to work. And that's the test code:

import ctypes

ctypes.CDLL('_lib/x86_64-darwin/libklusolve.dylib')      # load KLUSolve
ctypes.CDLL('_lib/x86_64-darwin/libopendssdirect.dylib') # load OpenDSSDirect
tshort commented 7 years ago

Thanks, @Muxelmann. I think I'm loading libklusolve.dylib first.

https://github.com/tshort/OpenDSSDirect.jl/blob/2d04ea2ec27c2865ba01836b80fb10f16d7952c7/src/core.jl#L15

Maybe Julia works differently than Python here. Without a local testbed, I probably can't debug this effectively. I may end up copying the libklusolve to a standard location. It's not great, but that works.

https://github.com/tshort/OpenDSSDirect.jl/pull/16