Home > Net >  How to include glm in opencl application?
How to include glm in opencl application?

Time:09-05

I'm tyring to include glm as a data structure types for vec3,..etc but I can't include it, it always complain about other headers like cmath.h is not found

err = clBuildProgram(program, 0, NULL, "-I C:\\Users\\xgame\\Desktop\\test\\opencl_raster\\external\\include\\glm", NULL, NULL);

In kernel:

#include "glm.hpp"



Could not open file: C:\Users\xgame\AppData\Local\Temp\dep-70203f.d
In file included from <kernel>:1:
In file included from C:\Users\xgame\Desktop\test\opencl_raster\external\include\glm\glm.hpp:81:
C:\Users\xgame\Desktop\test\opencl_raster\external\include\glm/detail/_fixes.hpp:33:10: fatal error: 'cmath' file not found
#include <cmath>
         ^

CodePudding user response:

While #include "some_header.h" works in OpenCL C, you cannot include C headers. OpenCL C is based on C99, not C ; it does not support a lot of C functionality like classes.

The good news is: OpenCL C already has cmath-like functionality and vector types built-in, for example the float3 vector type. No need to include headers for that or write it yourself.

Available math functionality and vector types are listed in this handy Reference Card.

  • Related