template <class Scalar>
struct Pattern24 {
// 00 01
//
// 02 03 04 05
//
// 06 07 08 09 10 11
//
// 12 13 14 15 16 17
//
// 18 19 20 21
//
// 22 23
//
// -----> x
// |
// |
// y
static constexpr Scalar pattern_raw[][2] = {
{-1, 5}, {1, 5},
{-3, 3}, {-1, 3}, {1, 3}, {3, 3},
{-5, 1}, {-3, 1}, {-1, 1}, {1, 1}, {3, 1}, {5, 1},
{-5, -1}, {-3, -1}, {-1, -1}, {1, -1}, {3, -1}, {5, -1},
{-3, -3}, {-1, -3}, {1, -3}, {3, -3},
{-1, -5}, {1, -5}
};
static constexpr int PATTERN_SIZE =
sizeof(pattern_raw) / (2 * sizeof(Scalar));
typedef Eigen::Matrix<Scalar, 2, PATTERN_SIZE> Matrix2P;
static const Matrix2P pattern2;
};
template <class Scalar>
const typename Pattern24<Scalar>::Matrix2P Pattern24<Scalar>::pattern2 =
Eigen::Map<Pattern24<Scalar>::Matrix2P>((Scalar*)
Pattern24<Scalar>::pattern_raw);
Above is the code I am trying to use in a project. But unfortunately while trying to link the files I get the following error:
[build] : && /opt/cuda/bin/g++
[build] /usr/bin/ld: CMakeFiles/odometry.dir/src/odometry.cpp.o: warning: relocation against `_ZN6visnav9Pattern24IfE11pattern_rawE' in read-only section `.text'
[build] /usr/bin/ld: CMakeFiles/odometry.dir/src/odometry.cpp.o: in function `__static_initialization_and_destruction_0(int, int)':
[build] undefined reference to `visnav::Pattern24<float>::pattern_raw'
[build] /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
[build] collect2: error: ld returned 1 exit status
After adding the above code as a header file to the project, it stopped compiling. I suspect the problem could because of my G++ version, which appears to be GCC 10.2.