A simple C++ library for reading .npy and .npz files generated from python numpy package save to file feature.
Useful for testing newly ad hoc code snippets where the snippet need to load a data array generated from python code into C++ code.
Its github page is here
adapted from [installation section](git clone https://github.com/rogersce/cnpy.git) of the repo
git clone https://github.com/rogersce/cnpy.git
sudo mkdir building
cd building
cmake ../cnpy
make
sudo make install
the last make install command should show you the path the library has been installed at, like this:
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libcnpy.so
-- Installing: /usr/local/lib/libcnpy.a
-- Installing: /usr/local/include/cnpy.h
-- Installing: /usr/local/bin/mat2npz
-- Installing: /usr/local/bin/npy2mat
-- Installing: /usr/local/bin/npz2mat
You can now compile ad hoc C++ programs by this:
g++ program.cpp -L/usr/local/lib -lcnpy -lz -o program
If after compilation, you tried to run the program but you got:
./program: error while loading shared libraries: libcnpy.so: cannot open shared object file: No such file or directory
run this
sudo ldconfig