Я попытался скомпилировать фланн, но у меня возникли некоторые ошибки при открытии файла hdf5.h об основании hdf5.h! При открытии этого файла вы можете найти импортировать себя в код! «#include» Как это случилось ?! И как я могу это исправить?
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
Вот ссылка hdf5.h:
Эта линия
#include <hdf5.h>
не относится к файлу ifself, но относится к другому файлу с тем же именем, который обычно находится в /usr/include
или каков путь вашего компилятора по умолчанию для включаемых файлов.
Однако вы, похоже, упускаете файлы разработчика библиотеки hdf5, которые должны включать /usr/include/hdf5.h
Вы можете найти их здесь: http://www.hdfgroup.org/downloads/index.html или в хранилище дистрибутива вашей ОС.
Я установил libflann-dev и пытался скомпилировать пример программы, указанный на Руководство FLANN, Я столкнулся с той же проблемой.
hdf5.h
заголовок доступен в различных вариантах пакета разработки (в Ubuntu), а именно libhdf5-dev
, libhdf5-mpich-dev
, libhdf5-openmpi-dev
, libhdf5-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
,