Pergunta

I tried to compile flann but I got some errors when opened hdf5.h file about founding the hdf5.h! when open this file you can found import himself into code! "#include " How this happened?! And how can i fix this?

In file included from src/CBIR.cpp:9:
./flann/io/hdf5.h:33:18: error: hdf5.h: No such file or directory
In file included from src/CBIR.cpp:9:
./flann/io/hdf5.h:43: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:48: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:49: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:50: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:51: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:52: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:53: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:54: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:55: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:56: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:57: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h:58: error: expected constructor, destructor, or type conversion before 'get_hdf5_type'
./flann/io/hdf5.h: In function 'void flann::save_to_file(const flann::Matrix<T>&, const std::string&, const std::string&)':
./flann/io/hdf5.h:67: error: 'herr_t' was not declared in this scope
./flann/io/hdf5.h:67: error: expected `;' before 'status'
./flann/io/hdf5.h:68: error: 'hid_t' was not declared in this scope
./flann/io/hdf5.h:68: error: expected `;' before 'file_id'
./flann/io/hdf5.h:69: error: 'file_id' was not declared in this scope
./flann/io/hdf5.h:71: error: 'hsize_t' was not declared in this scope
./flann/io/hdf5.h:71: error: expected `;' before 'dimsf'
./flann/io/hdf5.h:72: error: 'dimsf' was not declared in this scope
./flann/io/hdf5.h:75: error: expected `;' before 'space_id'
./flann/io/hdf5.h:76: error: expected `;' before 'memspace_id'
./flann/io/hdf5.h:78: error: expected `;' before 'dataset_id'
./flann/io/hdf5.h:79: error: 'dataset_id' was not declared in this scope
./flann/io/hdf5.h:81: error: 'status' was not declared in this scope
./flann/io/hdf5.h:81: error: 'dataset_id' was not declared in this scope
./flann/io/hdf5.h:81: error: 'get_hdf5_type' was not declared in this scope
./flann/io/hdf5.h:81: error: expected primary-expression before '>' token
./flann/io/hdf5.h:81: error: expected primary-expression before ')' token
./flann/io/hdf5.h:81: error: 'memspace_id' was not declared in this scope
./flann/io/hdf5.h:81: error: 'space_id' was not declared in this scope
./flann/io/hdf5.h:81: error: 'H5P_DEFAULT' was not declared in this scope
./flann/io/hdf5.h:84: error: there are no arguments to 'H5Sclose' that depend on a template parameter, so a declaration of 'H5Sclose' must be available
./flann/io/hdf5.h:84: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
./flann/io/hdf5.h:85: error: there are no arguments to 'H5Sclose' that depend on a template parameter, so a declaration of 'H5Sclose' must be available
./flann/io/hdf5.h:86: error: there are no arguments to 'H5Dclose' that depend on a template parameter, so a declaration of 'H5Dclose' must be available
./flann/io/hdf5.h:87: error: 'file_id' was not declared in this scope
./flann/io/hdf5.h:87: error: there are no arguments to 'H5Fclose' that depend on a template parameter, so a declaration of 'H5Fclose' must be available
./flann/io/hdf5.h: In function 'void flann::load_from_file(flann::Matrix<T>&, const std::string&, const std::string&)':
./flann/io/hdf5.h:95: error: 'herr_t' was not declared in this scope
./flann/io/hdf5.h:95: error: expected `;' before 'status'
./flann/io/hdf5.h:96: error: 'hid_t' was not declared in this scope
./flann/io/hdf5.h:96: error: expected `;' before 'file_id'
./flann/io/hdf5.h:97: error: 'file_id' was not declared in this scope
./flann/io/hdf5.h:99: error: expected `;' before 'dataset_id'
./flann/io/hdf5.h:100: error: 'dataset_id' was not declared in this scope
./flann/io/hdf5.h:102: error: expected `;' before 'space_id'
./flann/io/hdf5.h:104: error: 'hsize_t' was not declared in this scope
./flann/io/hdf5.h:104: error: expected `;' before 'dims_out'
./flann/io/hdf5.h:105: error: 'space_id' was not declared in this scope
./flann/io/hdf5.h:105: error: 'dims_out' was not declared in this scope
./flann/io/hdf5.h:105: error: there are no arguments to 'H5Sget_simple_extent_dims' that depend on a template parameter, so a declaration of 'H5Sget_simple_extent_dims' must be available
./flann/io/hdf5.h:109: error: 'status' was not declared in this scope
./flann/io/hdf5.h:109: error: 'dataset_id' was not declared in this scope
./flann/io/hdf5.h:109: error: 'get_hdf5_type' was not declared in this scope
./flann/io/hdf5.h:109: error: expected primary-expression before '>' token
./flann/io/hdf5.h:109: error: expected primary-expression before ')' token
./flann/io/hdf5.h:109: error: 'H5S_ALL' was not declared in this scope
./flann/io/hdf5.h:109: error: 'H5P_DEFAULT' was not declared in this scope
./flann/io/hdf5.h:112: error: there are no arguments to 'H5Sclose' that depend on a template parameter, so a declaration of 'H5Sclose' must be available
./flann/io/hdf5.h:113: error: there are no arguments to 'H5Dclose' that depend on a template parameter, so a declaration of 'H5Dclose' must be available
./flann/io/hdf5.h:114: error: 'file_id' was not declared in this scope
./flann/io/hdf5.h:114: error: there are no arguments to 'H5Fclose' that depend on a template parameter, so a declaration of 'H5Fclose' must be available
./flann/io/hdf5.h: In function 'void flann::save_to_file(const flann::Matrix<T>&, const std::string&, const std::string&) [with T = float]':src/CBIR.cpp:62:   instantiated from here
./flann/io/hdf5.h:81: error: 'H5Dwrite' was not declared in this scope
./flann/io/hdf5.h:81: error: 'H5Sclose' was not declared in this scope
./flann/io/hdf5.h:81: error: 'H5Dclose' was not declared in this scope
./flann/io/hdf5.h:87: error: 'H5Fclose' was not declared in this scope
./flann/io/hdf5.h: In function 'void flann::load_from_file(flann::Matrix<T>&, const std::string&, const std::string&) [with T = float]':
src/CBIR.cpp:83:   instantiated from here
./flann/io/hdf5.h:105: error: 'H5Sget_simple_extent_dims' was not declared in this scope
src/CBIR.cpp:83:   instantiated from here
./flann/io/hdf5.h:109: error: 'H5Dread' was not declared in this scope
./flann/io/hdf5.h:105: error: 'H5Sclose' was not declared in this scope
./flann/io/hdf5.h:109: error: 'H5Dclose' was not declared in this scope
./flann/io/hdf5.h:114: error: 'H5Fclose' was not declared in this scope
Makefile:43: recipe for target `src/CBIR.o' failed
make: *** [src/CBIR.o] Error 1

Here is hdf5.h link:

hdf5.h

Foi útil?

Solução

This line

#include <hdf5.h>

does not refer to the file ifself but to another file with the same name expected to be located typically under /usr/include or whatever your compiler's default path for include files is.

However you seem to be missing the hdf5 library developer files, which should include /usr/include/hdf5.h

You might either find them here: http://www.hdfgroup.org/downloads/index.html or in the repository of your OS distribution.

Outras dicas

I had installed libflann-dev and was trying to compile the sample program given at FLANN Manual, I faced the same problem.

hdf5.h header is available under different development package variations (in Ubuntu) namely libhdf5-dev, libhdf5-mpich-dev, libhdf5-openmpi-dev, libhdf5-mpi-dev etc, but they are put under their respective include directories as

/usr/include/hdf5/openmpi/hdf5.h
/usr/include/hdf5/mpich/hdf5.h
/usr/include/hdf5/serial/hdf5.h

So, while compiling if the relevant base path is provided as -I /usr/include/hdf5/serial/ the compilation goes well. Given I had chosen the serial version of hdf5, I had to use the respective library file libhdf5_serial. So, the compilation command becomes:

g++ flann_example.cpp -I /usr/include/hdf5/serial/ -lhdf5_serial

Alternately, one may create a soft link at /usr/include/hdf5.h pointing to /usr/include/hdf5/serial/hdf5.h.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top