AcademySoftwareFoundation / Imath

Imath is a C++ and python library of 2D and 3D vector, matrix, and math operations for computer graphics

Home Page:https://imath.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error compiling with nvcc

lashgar opened this issue · comments

Compiling following program with nvcc:

#include <Imath/ImathTypeTraits.h>
int main()
{
  return 0;
}

Generates following errors:

./Imath/ImathTypeTraits.h:194:86: error: ‘type name’ declared as function returning an array
  194 |     template<typename C,
      |                                                                                      ^
./Imath/ImathTypeTraits.h:194:93: error: lambda-expression in unevaluated context only available with ‘
-std=c++2a’ or ‘-std=gnu++2a’
  194 |     template<typename C,
      |                                                                                             ^
./Imath/ImathTypeTraits.h:194:86: error: ‘type name’ declared as function returning an array
  194 |     template<typename C,
      |                                  

Compile command: nvcc toy.cu -I /path/to/Imath/include/
Imath version: v3.1.4 release
nvcc version: 11.5
gcc version: 9.3.0

Apologies for the delay in responding, and you may have figured things out already, but I suspect that nvcc is defaulting to an old C++ version. Those errors look like they're coming from a compiler with settings for pre-C++11. I've encountered problems like this on systems where the default installation of gcc is 4.8.5, in which case you have to manual direct nvcc to the right settings. Can you try again with:

nvcc -std=c++11 toy.cu -I/path/to/Imath/include

Or alternatively, nvcc -ccbin to specify the location of gcc?

ImathTypeTraits.h definitely compiles and runs properly with nvcc 10.1 and gcc 9.3.

I'm having exactly the same issue.

Imath 3.1.6
nvcc 12.3

I've tried combinations of:

{ -ccbin=gcc-6, -ccbin=gcc-9}
and
{-std=c++11, -std=c++14, -std=c++17}

but nothing has worked. The error messages differ slightly for each case, but a few of them seem to suggest that -std=c++20 is the fix. I haven't been able to try that because I only have access to gcc-9 at the latest (which sounds like should work).

/include/Imath/ImathTypeTraits.h:221:86: error: ‘type name’ declared as function returning an array
  221 |     template<typename C,
      |                                                                                      ^
/include/Imath/ImathTypeTraits.h:221:93: error: lambda-expression in unevaluated context only available with ‘-std=c++20or ‘-std=gnu++20