xelatihy / yocto-gl

Yocto/GL: Tiny C++ Libraries for Data-Driven Physically-based Graphics
https://xelatihy.github.io/yocto-gl
2.83k stars 207 forks source link

Can't compile cutrace on Linux (gcc / clang) #1438

Closed TerminalTit closed 1 year ago

TerminalTit commented 1 year ago

Hello! Trying to compile project on Linux machine (Ubuntu 22) Ubuntu clang version 14.0.0-1ubuntu1.1 Found CUDA installation: /usr/lib/cuda, version 11.5 Optix installed

I have the same error in gcc compiler

File yocto_cutrace.h Line 360 // empty stb record struct __declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { __declspec(align( OPTIX_SBT_RECORD_ALIGNMENT)) char header[OPTIX_SBT_RECORD_HEADER_SIZE]; };

Errors:

Screenshot 2023-09-02 at 11 35 24

/home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: expected parameter declarator In file included from /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:29: /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:25: error: expected parameter declarator struct __declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { ^ /home/manager/Projects/yocto-gl-main/exts/optix/include/optix_types.h:82:36: note: expanded from macro 'OPTIX_SBT_RECORD_ALIGNMENT'

define OPTIX_SBT_RECORD_ALIGNMENT 16ull

                               ^

/home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: expected ')' In file included from /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:29: /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:25: error: expected ')' /home/manager/Projects/yocto-gl-main/exts/optix/include/optix_types.h:82:36: note: expanded from macro 'OPTIX_SBT_RECORD_ALIGNMENT'

define OPTIX_SBT_RECORD_ALIGNMENT 16ull

                               ^

/home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:24: note: to match this '(' struct declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: expected function body after function declarator /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:54: error: expected function body after function declarator struct declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:382: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:382:10: error: use of undeclared identifier 'cutrace_stbrecord' cuspan raygen_records = {}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:383: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:383:10: error: use of undeclared identifier 'cutrace_stbrecord' cuspan miss_records = {}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:384: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:384:10: error: use of undeclared identifier 'cutrace_stbrecord' cuspan hitgroup_records = {}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:431: error: use of undeclared identifier 'optixModuleCreateFromPTX'; did you mean 'optixModuleCreate'? /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:431:16: error: use of undeclared identifier 'optixModuleCreateFromPTX'; did you mean 'optixModuleCreate'? check_result(optixModuleCreateFromPTX(context.optix_context, &module_options, ^~~~~~~~ optixModuleCreate /home/manager/Projects/yocto-gl-main/exts/optix/include/optix_stubs.h:381:20: note: 'optixModuleCreate' declared here inline OptixResult optixModuleCreate( OptixDeviceContext context, ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:478: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:478:24: error: use of undeclared identifier 'cutrace_stbrecord' auto raygen_record = cutrace_stbrecord{}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:478: error: expected ';' at end of declaration /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:478:41: error: expected ';' at end of declaration auto raygen_record = cutrace_stbrecord{}; ^ ; /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:485: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:485:22: error: use of undeclared identifier 'cutrace_stbrecord' auto miss_record = cutrace_stbrecord{}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:485: error: expected ';' at end of declaration /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:485:39: error: expected ';' at end of declaration auto miss_record = cutrace_stbrecord{}; ^ ; /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:489: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:489:58: error: use of undeclared identifier 'cutrace_stbrecord' context.binding_table.missRecordStrideInBytes = sizeof(cutrace_stbrecord); ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:493: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:493:26: error: use of undeclared identifier 'cutrace_stbrecord' auto hitgroup_record = cutrace_stbrecord{}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:493: error: expected ';' at end of declaration /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:493:43: error: expected ';' at end of declaration auto hitgroup_record = cutrace_stbrecord{}; ^ ; /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:499: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:499:62: error: use of undeclared identifier 'cutrace_stbrecord' context.binding_table.hitgroupRecordStrideInBytes = sizeof(cutrace_stbrecord); ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:814: error: use of undeclared identifier 'memcpy'; did you mean 'wmemcpy'? /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:814:7: error: use of undeclared identifier 'memcpy'; did you mean 'wmemcpy'? memcpy(opinstance.transform, &transform, sizeof(float) 12); ^~ wmemcpy /usr/include/wchar.h:263:17: note: 'wmemcpy' declared here extern wchar_t wmemcpy (wchar_t restrict s1, ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:814: error: cannot initialize a parameter of type 'wchar_t ' with an lvalue of type 'float[12]' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:814:14: error: cannot initialize a parameter of type 'wchar_t ' with an lvalue of type 'float[12]' memcpy(opinstance.transform, &transform, sizeof(float) 12); ^~~~~~~~ /usr/include/wchar.h:263:46: note: passing argument to parameter 's1' here extern wchar_t wmemcpy (wchar_t restrict __s1, ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:1122: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'unsigned int' in initializer list [-Wc++11-narrowing] /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:1122:27: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'unsigned int' in initializer list [-Wc++11-narrowing] (uint)state.height, (uint)state.width sizeof(vec3f), sizeof(vec3f), ^~~~~~~~~ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:1122:27: note: insert an explicit cast to silence this issue (uint)state.height, (uint)state.width sizeof(vec3f), sizeof(vec3f), ^~~~~~~~~ static_cast( ) /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:1125: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'unsigned int' in initializer list [-Wc++11-narrowing] /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:1125:27: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'unsigned int' in initializer list [-Wc++11-narrowing] (uint)state.height, (uint)state.width sizeof(vec3f), sizeof(vec3f), ^~~~~~~~~ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.cpp:1125:27: note: insert an explicit cast to silence this issue (uint)state.height, (uint)state.width sizeof(vec3f), sizeof(vec3f), ^~~~~~~~~ static_cast( ) fatal error: too many errors emitted, stopping now [-ferror-limit=] /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: expected parameter declarator In file included from /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_gui.cpp:41: /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:25: error: expected parameter declarator struct __declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { ^ /home/manager/Projects/yocto-gl-main/exts/optix/include/optix_types.h:82:36: note: expanded from macro 'OPTIX_SBT_RECORD_ALIGNMENT'

define OPTIX_SBT_RECORD_ALIGNMENT 16ull

                               ^

/home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: expected ')' In file included from /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_gui.cpp:41: /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:25: error: expected ')' /home/manager/Projects/yocto-gl-main/exts/optix/include/optix_types.h:82:36: note: expanded from macro 'OPTIX_SBT_RECORD_ALIGNMENT'

define OPTIX_SBT_RECORD_ALIGNMENT 16ull

                               ^

/home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:24: note: to match this '(' struct declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: expected function body after function declarator /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361:54: error: expected function body after function declarator struct declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:382: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:382:10: error: use of undeclared identifier 'cutrace_stbrecord' cuspan raygen_records = {}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:383: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:383:10: error: use of undeclared identifier 'cutrace_stbrecord' cuspan miss_records = {}; ^ /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:384: error: use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:384:10: error: use of undeclared identifier 'cutrace_stbrecord' cuspan hitgroup_records = {}; ^ : - 1: error: ninja: build stopped: subcommand failed. /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: Expected parameter declarator /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: Expected ')' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: To match this '(' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:361: error: Expected function body after function declarator /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:382: error: Use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:383: error: Use of undeclared identifier 'cutrace_stbrecord' /home/manager/Projects/yocto-gl-main/libs/yocto/yocto_cutrace.h:384: error: Use of undeclared identifier 'cutrace_stbrecord'

TerminalTit commented 1 year ago

The problem gone. Change line 360

// empty stb record struct __declspec(align(OPTIX_SBT_RECORD_ALIGNMENT)) cutrace_stbrecord { __declspec(align( OPTIX_SBT_RECORD_ALIGNMENT)) char header[OPTIX_SBT_RECORD_HEADER_SIZE]; };

to

// empty stb record struct __attribute__((aligned(OPTIX_SBT_RECORD_ALIGNMENT))) cutrace_stbrecord { __attribute__((aligned( OPTIX_SBT_RECORD_ALIGNMENT))) char header[OPTIX_SBT_RECORD_HEADER_SIZE]; };