Facing the CUDA-12 + GLib issue macro clash issue

23 visualizaciones (últimos 30 días)
Syed Muhammad
Syed Muhammad el 11 de Sept. de 2025 a las 9:27
Comentada: Isha el 19 de Sept. de 2025 a las 10:38
I am working on MATLAB - Jetson, i am running a MATLAB example, Fog Recitfication on NVIDIA Jetson, i will share the code so that you can understand the issue,
function fog_rectification() %#codegen
% coder.updateBuildInfo('addNonBuildFiles','mw_noinline_fix.h');
% coder.updateBuildInfo('addIncludePaths','.');
% coder.updateBuildInfo('addCompileFlags','-include mw_noinline_fix.h');
coder.gpu.kernelfun;
hwobj = jetson();
width = 600;
height = 404;
videoFileName = 'foggy.mp4';
vobj = VideoReader(hwobj,videoFileName,'Width',width,'Height',height);
dispObj = imageDisplay(hwobj);
while vobj.hasFrame
input = vobj.readFrame;
% Run fog rectification on the frame
outrectifiedImage = fog_rectification_algorithm (input,width,height);
reshapedImg = cat(3, outrectifiedImage(:,:,1).', ...
outrectifiedImage(:,:,2)',outrectifiedImage(:,:,3)');
image(dispObj,reshapedImg);
end
end
and here is the MATLAB code for data generation
hwobj = jetson('169.254.172.219','hr','0000');
envCfg = coder.gpuEnvConfig('jetson');
envCfg.BasicCodegen = 1;
envCfg.Quiet = 1; envCfg.HardwareObject = hwobj;
coder.checkGpuInstall(envCfg); cfg = coder.gpuConfig('exe');
cfg.Hardware = coder.hardware('NVIDIA Jetson');
cfg.Hardware.BuildDir = '~/remoteBuildDir2';
cfg.GenerateExampleMain = 'GenerateCodeAndCompile';
codegen('-config ',cfg,'fog_rectification','-report');
the error i am facing is..
Error executing command "touch -c /home/hr/remoteBuildDir2/MATLAB_ws/R2024a/C/Users/Syed_Jameel/OneDrive/Documents/MATLAB/Examples/R2024a/nvidia/FogRectificationForVideoOnNVIDIAJetsonExample/codegen/exe/fog_rectification/*.*;make -f fog_rectification_rtw.mk -j4 all MATLAB_WORKSPACE="/home/hr/remoteBuildDir2/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/hr/remoteBuildDir2/MATLAB_ws/R2024a/C/Users/Syed_Jameel/OneDrive/Documents/MATLAB/Examples/R2024a/nvidia/FogRectificationForVideoOnNVIDIAJetsonExample/codegen/exe/fog_rectification". Details
STDERR: In file included from /usr/lib/aarch64-linux-gnu/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/gstreamer-1.0/gst/gst.h:27,
from /home/hr/remoteBuildDir2/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/target/supportpackages/nvidia/sources/server/frameReader.h:5,
from /home/hr/remoteBuildDir2/MATLAB_ws/R2024a/C/Users/Syed_Jameel/OneDrive/Documents/MATLAB/Examples/R2024a/nvidia/FogRectificationForVideoOnNVIDIAJetsonExample/codegen/exe/fog_rectification/fog_rectification.cu:23:
/usr/include/glib-2.0/glib/gmacros.h:249:28: error: missing ')' after "__has_attribute"
249 | #if g_macro__has_attribute(__noinline__)
| ^~~~~~~~~~~~
In file included from /usr/local/cuda/bin/../targets/aarch64-linux/include/device_types.h:59,
from /usr/local/cuda/bin/../targets/aarch64-linux/include/builtin_types.h:56,
from /usr/local/cuda/bin/../targets/aarch64-linux/include/cuda_runtime.h:90,
from <command-line>:/usr/local/cuda/bin/../targets/aarch64-linux/include/crt/host_defines.h:83:23: error: missing binary operator before token "( 83 | __attribute__((noinline))
  2 comentarios
Ramakrishna Mandalapu
Ramakrishna Mandalapu el 12 de Sept. de 2025 a las 6:08
Hi Syed,
Can you provide the Jetson board type and the MATLAB version used?
Thanks,
Ramakrishna
Isha
Isha el 19 de Sept. de 2025 a las 10:38
Hello Syed,
This is a known issue: both GLib and CUDA use the identifier __noinline__ (and related attribute checks like __has_attribute) in their headers. Wrap your includes so CUDA’s __noinline__ doesn’t pollute GLib headers:
// In a custom header, e.g. mw_noinline_fix.h
#ifdef __CUDACC__
#pragma push_macro("__noinline__")
#undef __noinline__
#endif
#include <glib.h>
#include <gst/gst.h>
#ifdef __CUDACC__
#pragma pop_macro("__noinline__")
#endif
Then, in MATLAB’s build info:
coder.updateBuildInfo('addIncludePaths','.');
coder.updateBuildInfo('addNonBuildFiles','mw_noinline_fix.h');
coder.updateBuildInfo('addCompileFlags','-include mw_noinline_fix.h');
This ensures GLib headers are parsed cleanly, and CUDA still gets __noinline__ where it needs it.
You can also refer to the link below:
Hope this helps.

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by