2

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

4

2 回答 2

4

这条线

#include <hdf5.h>

不是指 ifself 文件,而是指另一个具有相同名称的文件,该文件通常位于/usr/include编译器的包含文件的默认路径下或任何位置。

但是,您似乎缺少 hdf5 库开发人员文件,其中应包括/usr/include/hdf5.h

您可以在这里找到它们:http ://www.hdfgroup.org/downloads/index.html或在您的操作系统发行版的存储库中。

于 2013-09-07T20:25:00.210 回答
1

我已经安装了 libflann-dev 并试图编译FLANN Manual中给出的示例程序,我遇到了同样的问题。

hdf5.h标头在不同的开发包变体(在 Ubuntu 中)下可用,即, ,libhdf5-devlibhdf5-mpich-dev,但它们放在各自的包含目录下libhdf5-openmpi-devlibhdf5-mpi-dev

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

-I /usr/include/hdf5/serial/因此,在编译时,如果在编译顺利时提供了相关的基本路径。鉴于我选择了 hdf5 的串行版本,我必须使用相应的库文件libhdf5_serial。因此,编译命令变为:

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

或者,可以创建/usr/include/hdf5.h指向的软链接/usr/include/hdf5/serial/hdf5.h

于 2015-08-14T11:53:12.070 回答