我试图通过使用其他代码包中的 Make 方法来编译 flann,但是我在一个 flann 二进制文件 './flann/util/matrix.h:75' 中收到有关受保护函数的错误,任何人都可以帮我解决这个问题错误?我真的是编程新手,请尽可能简单!:P
g++ -I. -Iflann/src/cpp -c -o src/main.o src/main.cpp
In file included from ./boost/asio/async_result.hpp:18,
from ./boost/asio.hpp:20,
from src/common.hpp:30,
from src/main.cpp:9:
./boost/asio/detail/config.hpp:367:5: warning: #warning Please define _WIN32_WIN NT or _WIN32_WINDOWS appropriately.
./boost/asio/detail/config.hpp:368:5: warning: #warning For example, add -D_WIN32_WINNT=0x0501 to the compiler command line.
./boost/asio/detail/config.hpp:369:5: warning: #warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
./flann/util/matrix.h: In function 'int cbir::main(int, char**)':
./flann/util/matrix.h:75: error: 'flann::uchar* flann::Matrix_::data' is protected
src/main.cpp:39: error: within this context
Makefile:43: recipe for target `src/main.o' failed
make: *** [src/main.o] Error 1
这是 matrix.h :
#ifndef FLANN_DATASET_H_
#define FLANN_DATASET_H_
#include "flann/general.h"
#include <stdio.h>
namespace flann
{
typedef unsigned char uchar;
class Matrix_
{
public:
Matrix_() : rows(0), cols(0), stride(0), data(NULL)
{
};
Matrix_(void* data_, size_t rows_, size_t cols_, flann_datatype_t type, size_t stride_ = 0) :
rows(rows_), cols(cols_), stride(stride_)
{
data = static_cast<uchar*>(data_);
if (stride==0) stride = flann_datatype_size(type)*cols;
}
inline void* operator[](size_t index) const
{
return data+index*stride;
}
void* ptr() const
{
return data;
}
size_t rows;
size_t cols;
size_t stride;
flann_datatype_t type;
protected:
uchar* data;
};
template <typename T>
class Matrix : public Matrix_
{
public:
typedef T type;
Matrix() : Matrix_()
{
}
Matrix(T* data_, size_t rows_, size_t cols_, size_t stride_ = 0) :
Matrix_(data_, rows_, cols_, flann_datatype<T>::value, stride_)
{
}
FLANN_DEPRECATED void free()
{
fprintf(stderr, "The flann::Matrix<T>::free() method is deprecated "
"and it does not do any memory deallocation any more. You are"
"responsible for deallocating the matrix memory (by doing"
"'delete[] matrix.ptr()' for example)");
}
inline T* operator[](size_t index) const
{
return reinterpret_cast<T*>(static_cast<uchar*>(Matrix_::data)+index*stride);
// return (T*)(Matrix_::operator [](index));
}
T* ptr() const
{
return reinterpret_cast<T*>(Matrix_::data);
}
};
}
#endif //FLANN_DATASET_H_