0

I am having difficulty in getting Eigen 3.3.7 to compile using QNX 6.5.0 or 6.6.0. When I attempt to compile the simple first program example, from the Eigen getting started page.

#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
  MatrixXd m(2,2);
  m(0,0) = 3;
  m(1,0) = 2.5;
  m(0,1) = -1;
  m(1,1) = m(1,0) + m(0,1);
  std::cout << m << std::endl;
}

Compiling with:

qcc -I. test_eigen.cpp

I get 18 errors all similar too:

In file included from ./Eigen/Core:411,
                 from ./Eigen/Dense:1,
                 from test_eigen.cpp:14:
./Eigen/src/Core/arch/CUDA/Half.h: In function 'Eigen::half Eigen::half_impl::exp(const Eigen::half&)':
./Eigen/src/Core/arch/CUDA/Half.h:454: error: '::expf' has not been declared

While I can fix these errors by adding 'std' before each missing function, this suggests there is a bigger problem that I need to fix. I have a feeling there are some clashing namespaces or preprocessor definitions. Any help would be gratefully received.

user827046
  • 21
  • 3

1 Answers1

0

Unlike most other platforms, QNX 6.x's C++ stdlib puts many of the cmath functions ONLY in the std namespace. This is technically legal according to the C++11 standard, although it does make portability challenging. Further, QNX still places them in the std namespace if you include the header as if it was C (ie. #include <cmath.h> still exposes std::expf, not ::expf).

Eigen, as you've noticed, explicitly expects them in the root namespace; as I understand things, in years gone by, not all C++ stdlib implementations were as diligent about placing C library functions in the std namespace.

As a workaround, you can use using directives to add them to the root namespace in your own source files:

#include <cmath>
using std::expf;
#include <Eigen/Dense>
Will Miles
  • 251
  • 1
  • 5