jllodra / ncdump-json

Modified ncdump to output data in json format
85 stars 28 forks source link

Incompatible with recent cmake versions + workaround #14

Open christianversloot opened 5 years ago

christianversloot commented 5 years ago

I'm currently migrating servers and am in the process of reinstalling ncdump-json. The installation instructions do however no longer work with the more recent versions of cmake due to syntax errors.

However, there is a workaround: cmake version 2.8.12.2. Posting it here for the sake of community knowledge.

Installing compatible CMake version

  1. Follow these installation instructions: https://geeksww.com/tutorials/operating_systems/linux/installation/downloading_compiling_and_installing_cmake_on_linux.php Important: instead of 2.8.3 in the wget command, use 2.8.12.2.

  2. In case you get any errors in the configure phase (e.g. due to C++ compilers not found or Fortran related errors), execute sudo apt-get install gcc gfortran g++ and try again.

Running the make command In the installation instructions, after $cmake, you'll have to run the make command from the ncdump-json folder. It may then be that you run into HDF5 errors:

Linking C executable ncdump-json
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
CMakeFiles/ncdump-json.dir/build.make:210: recipe for target 'ncdump-json' failed
make[2]: *** [ncdump-json] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/ncdump-json.dir/all' failed
make[1]: *** [CMakeFiles/ncdump-json.dir/all] Error 2
Makefile:113: recipe for target 'all' failed
make: *** [all] Error 2

To solve this, first ensure that you have installed the proper HDF5 dependencies:

sudo apt-get install libhdf5-serial-dev

Try again. If you get the same error, there is a mismatch between where your system has installed the files and where the makefile expects them to be.

To solve this, execute these steps:

  1. Move into the relevant dir: cd /usr/lib/x86_64-linux-gnu
  2. Execute ls | grep libhdf5.
  3. Find the correct 'version ish number' behind the file name specified next. For example: libhdf5_serial.so.8.0.2 or, in my case, libhdf5_serial.so.100.
  4. Create two hard links:
sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

Important: make sure to replace 8.0.2 with the number you identified in step 3.

  1. Move towards the ncdump-json directory, e.g. /home/username/ncdump-json.
  2. Run make again.

The error disappeared and I got it running:

Linking C executable ncdump-json
[100%] Built target ncdump-json

Obviously, I ran this on a Unix based system with one of the more recent version of Debian (9). I hope it benefits some of you as it cost me several hours to figure it out, which will probably save some time for anyone dealing with this as well :)

christianversloot commented 5 years ago

Augmented issue desciption with full steps towards installing ncdump-json with compatible cmake version.

jllodra commented 5 years ago

Hi @christianversloot,

Thank you for sharing your experience and providing workarounds.

Let me add that if you have the time to update or improve the CMakeLists.txt file to make compiling and linking better and more homogeneus between systems, I will be happy to review and merge a pull-request.