I'm quite new to C++ and armadillo, and I get stuck with a building error describe below. I'm trying to test the following simple code to save an armadillo matrix as hdf5 file:
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int main()
{
mat A = randu<mat>(240,320);
A.save("A.hdf5",hdf5_binary);
return 0;
}
When compiling, I get the following errors:
/usr/include/armadillo_bits/hdf5_misc.hpp:131: undefined reference in « arma_H5T_NATIVE_DOUBLE »
/usr/include/armadillo_bits/hdf5_misc.hpp:131: undefined reference in « arma_H5Tcopy »
obj/Debug/main.o: in function « bool arma::diskio::save_hdf5_binary<double> (arma::Mat<double> const&, std::string const&) »:
/usr/include/armadillo_bits/diskio_meat.hpp:1299: undefined reference in « arma_H5Eset_auto »
/usr/include/armadillo_bits/diskio_meat.hpp:1308: undefined reference in « arma::H5check_version(unsigned int, unsigned int, unsigned int) »
/usr/include/armadillo_bits/diskio_meat.hpp:1308: undefined reference in « arma_H5Fcreate »
/usr/include/armadillo_bits/diskio_meat.hpp:1315: undefined reference in « arma_H5Screate_simple »
/usr/include/armadillo_bits/diskio_meat.hpp:1324: undefined reference in « arma_H5Dcreate »
/usr/include/armadillo_bits/diskio_meat.hpp:1330: undefined reference in « arma_H5Dwrite »
/usr/include/armadillo_bits/diskio_meat.hpp:1333: undefined reference in « arma_H5Dclose »
/usr/include/armadillo_bits/diskio_meat.hpp:1334: undefined reference in « arma_H5Tclose »
/usr/include/armadillo_bits/diskio_meat.hpp:1335: undefined reference in « arma_H5Sclose »
/usr/include/armadillo_bits/diskio_meat.hpp:1336: undefined reference in « arma_H5Fclose »
The compilation instruction is as follow:
g++ -Wall -fexceptions -O2 -g -larmadillo -lhdf5 -c main.cpp -o main
I'm working with CodeBlocks on a linux Fedora 20 system. I have the packaged HDF5-devel and could find the hdf5.h in /usr/include/
I also activated hdf5 in armadillo using the #define ARMA_USE_HDF5
in config.hpp
. I use the latest version of armadillo (4.450) and gcc 4.8.3.
Did I missed a link ? To me, adding -larmadillo and -lhdf5 (as said in armadillo's users guide) should be enough. Any clue ? Thanks