Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking hdf5.node to static hdf5 C library #56

Open
jprctr opened this issue Mar 2, 2018 · 13 comments
Open

Linking hdf5.node to static hdf5 C library #56

jprctr opened this issue Mar 2, 2018 · 13 comments

Comments

@jprctr
Copy link

jprctr commented Mar 2, 2018

I'm using hdf5.node as part of an electron app, and I'd like to link it to a static version of the hdf5 C library so that a user will not need to install hdf5 separately to use my app.

On my local machine, a mac, revising hdf5.node's binding.gyp to link to somefile.a instead of somefile.dylib and then rebuilding hdf5.node with electron-rebuild successfully produces a statically linked version of the library that can be packed with an electron app and run on a system that does not have the hdf5 C library installed.

However, not all features of the rebuilt hdf5.node behave in the expected way. I am able to load a hdf5 formatted file, and view some of it's contents, for example, the file's child groups. But, when attempting to read datasets, an error is produced. Specifically, the error is:
Uncaught SyntaxError: failed to find dataset rank

I've read through your response to issue #22, so I realize that this might not be a feature you plan to address or support in the near term. If that is the case, would you be willing to point me towards the areas that might need to be altered to successfully link to the static version of hdf5 with all the features intact?

Thanks!
binding.gyp.zip

@rimmartin
Copy link
Collaborator

Let me look a bit; see if a switch can be added to make binding.gyp link either way. As yet I'm unsure what would be different with reading datasets or any h5 operation. Thanks for the experimental binding.gyp.zip

@rimmartin
Copy link
Collaborator

Hi,

I put in a binding.gyp variable for choosing shared or static switch on the compilers

https://github.com/HDF-NI/hdf5.node/blob/master/binding.gyp#L6

only tested on linux so far; need to get access to a mac at work and test there.

Didn't work with the .dylib vs .a yet; want to see if it is possibly to do it with -l like linux so these wouldn't need direct paths.

Typical build line is:

npm install --fallback-to-build --link_type=static --hdf5_home_linux=$HDF5_HOME

@jprctr
Copy link
Author

jprctr commented Mar 6, 2018

Thanks for digging into this! Using a switch does seem like a better solution.

I tried building with the line you provided on the mac (after pulling in the latest changes you referenced above), and while it does complete successfully it's still referencing the shared library.

This may be because the mac link settings still reference the dylibs explicitly (unlike linux which doesn't include an extension).

@rimmartin
Copy link
Collaborator

Right, I have a mac at work; it just needed the security update to work again with github.

I built a special hdf5 native lib that had no shared libraries available and that helps debug the static build. Be trying on mac when it works hopefully later this week

@joshua-gould
Copy link

joshua-gould commented Mar 16, 2018

I tried on my Mac and it was unable to find the shared library when using Electron.

@rimmartin
Copy link
Collaborator

set the path to –hdf5_home_mac= ?
I'll be testing tonight. Got delayed over the weekend

@joshua-gould
Copy link

joshua-gould commented Mar 19, 2018 via email

@rimmartin
Copy link
Collaborator

The work box I get to use uses the gcc compiler(or it's proprietary project) instead of clang; believe causing troubles with node-gyp project setup. Looking for some way thru this. The only mac people I know are too paranoid of changes to let me set up developer env for this:-) Still trying to find away. May publish for the other fixes and come back to this

@rimmartin
Copy link
Collaborator

Successfully building for linux and mac on travis-ci-org https://travis-ci.org/HDF-NI/hdf5.node/

fixing some unit tests that only fail on travis-ci for me

@joshua-gould
Copy link

Works for me too.

@rimmartin
Copy link
Collaborator

changed the binding.gyp; static builds with mac could now possibly work

@jprctr
Copy link
Author

jprctr commented Jun 12, 2018

Finally had a chance to try this out - thanks for taking the time to make these updates.

I installed the latest version of hdf5.node from this repository to my project, edited the link_type% in the binding.gyp file to specify "static" rather than "shared", and finally, rebuilt the library.

The rebuild succeeds and runs fine on my local machine. However, when I move it to another mac and attempt to run I get the following error:

Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.101.dylib

Have I missed a step somewhere here?

@rimmartin
Copy link
Collaborator

I don't think you missed anything. I'll try with the travis build and learn more about mac static style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants