CerebusOSS/CereLink

Building n2h5 on OS X

Closed this issue · 6 comments

Even though I have hdf5 installed (with homebrew) on Mac OS X Mavericks, I get the following error when I run "cmake .":

sdangi$ cmake .
-- checking for module 'python-2.7'
--   package 'python-2.7' not found
-- Found Python executable: /usr/local/bin/python
-- Found Python version: 2.7.6
-- Found Python library: -F/usr/local/Frameworks -framework Python
-- Search mex libraries at MATLAB_INCLUDE_DIR-NOTFOUND/../lib/osx64
-- Add cbpy build target using Python found at /usr/local/bin/python
-- Add n2h5 utility build target
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
HDF5_HL_LIBRARIES
    linked by target "n2h5" in directory /Users/sdangi/code/CereLink/build

-- Configuring incomplete, errors occurred!
See also "/Users/sdangi/code/CereLink/build/CMakeFiles/CMakeOutput.log".
See also "/Users/sdangi/code/CereLink/build/CMakeFiles/CMakeError.log".
sdangi$ brew install hdf5
Warning: hdf5-1.8.12 already installed

(Up until now, I've just been commenting out the n2h5 part of CMakeLists.txt in order to avoid this error, but now I want to actually use n2h5.)

In OS X, the HDF5 shared libraries (installed into /usr/local/lib by homebrew) have a .dylib extension instead of .so:

sdangi$ cd /usr/local/lib
sdangi$ ls -l | grep hdf5
lrwxr-xr-x   1 sdangi  admin      41 Jan 21 17:57 libhdf5.8.dylib -> ../Cellar/hdf5/1.8.12/lib/libhdf5.8.dylib
lrwxr-xr-x   1 sdangi  admin      35 Jan 21 17:57 libhdf5.a -> ../Cellar/hdf5/1.8.12/lib/libhdf5.a
lrwxr-xr-x   1 sdangi  admin      39 Jan 21 17:57 libhdf5.dylib -> ../Cellar/hdf5/1.8.12/lib/libhdf5.dylib
lrwxr-xr-x   1 sdangi  admin      42 Jan 21 17:57 libhdf5.settings -> ../Cellar/hdf5/1.8.12/lib/libhdf5.settings
lrwxr-xr-x   1 sdangi  admin      44 Jan 21 17:57 libhdf5_hl.8.dylib -> ../Cellar/hdf5/1.8.12/lib/libhdf5_hl.8.dylib
lrwxr-xr-x   1 sdangi  admin      38 Jan 21 17:57 libhdf5_hl.a -> ../Cellar/hdf5/1.8.12/lib/libhdf5_hl.a
lrwxr-xr-x   1 sdangi  admin      42 Jan 21 17:57 libhdf5_hl.dylib -> ../Cellar/hdf5/1.8.12/lib/libhdf5_hl.dylib

However, for target n2h5, CMakeLists.txt looks specifically for libhdf5_hl.so:

        FIND_LIBRARY (HDF5_HL_LIBRARIES libhdf5_hl.so

A fix to this issue is achieved by either:

  1. Changing the ".so" in the line above to "*"
  2. Detecting with the OS is mac, linux, etc., and searching specifically for libhdf5_hl.dylib, .so, etc. based on that

I did a small commit (removed .so extension), it works still on Linux, if it works on OSX we can close this

Yup, with .so removed, it builds fine on OS X. I'm closing the issue.

Oops -- with .so removed, it actually doesn't work on linux (n2h5 build target is not added when running cmake .). Maybe change it to .* ?

FIND_LIBRARY (HDF5_HL_LIBRARIES libhdf5_hl.*

sure, I tried it once, perhaps my CMake cache was not refreshed then, or maybe it is distro specific.

This should work now