Clear Filters
Clear Filters

Issue generating mex file for librealsense

3 views (last 30 days)
Hello,
I have been facing issues generating a mex file from librealsense_mex.cpp. My setup has MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation. Everything is in the correct paths but I get large amount of error which appear to be due to compilation? Inserting some below.
Appreciate any help
In file included from C:\Users\Silicon
Synapse\Downloads\librealsense-master\librealsense-master\wrappers\matlab\MatlabParamParser.h:340:0,
from C:\Users\Silicon Synapse\Downloads\librealsense-master\librealsense-master\wrappers\matlab\librealsense_mex.cpp:1:
C:\Users\Silicon Synapse\Downloads\librealsense-master\librealsense-master\wrappers\matlab\types.h:229:126: error: specialization of
'template<class T> typename std::enable_if<((! std::integral_constant<bool, ((std::is_arithmetic<_Tp>::value ||
std::is_pointer<_Tp>::value) || std::is_enum<_Tp>::value)>::value) && (! std::integral_constant<bool,
MatlabParamParser::traits_trampoline::detector<T>::use_cells>::value)), mxArray_tag*>::type MatlabParamParser::wrap_array(const T*,
size_t)' in different namespace [-fpermissive]
template <> mxArray* MatlabParamParser::wrap_array<rs2::texture_coordinate>(const rs2::texture_coordinate* var, size_t length)
^
In file included from C:\Users\Silicon
Synapse\Downloads\librealsense-master\librealsense-master\wrappers\matlab\librealsense_mex.cpp:1:0:
C:\Users\Silicon Synapse\Downloads\librealsense-master\librealsense-master\wrappers\matlab\MatlabParamParser.h:311:1: error: from
definition of 'template<class T> typename std::enable_if<((! std::integral_constant<bool, ((std::is_arithmetic<_Tp>::value ||
std::is_pointer<_Tp>::value) || std::is_enum<_Tp>::value)>::value) && (! std::integral_constant<bool,
MatlabParamParser::traits_trampoline::detector<T>::use_cells>::value)), mxArray_tag*>::type MatlabParamParser::wrap_array(const T*,
size_t)' [-fpermissive]
MatlabParamParser::wrap_array(const T* var, size_t length)

Answers (1)

Maneet Kaur Bagga
Maneet Kaur Bagga on 2 May 2024
Hi,
As per my understanding the error encountered is about the template specialization for "MatlabParamParser::wrap_array<rs2::texture_coordinate>" being declared in a different namespace than its original template declaration as indicated by the "-fpermissive" flag in the error message, which suggests that the compiler expects the specialization to be declared within the same namespace as the original template.
The possible workaround for this could be:
  1. Check if the template specialization for the "wrap_array" is declared within the same namespace as its original template declaration.
  2. If the specialization is intended to be in the "MatlabParamParser" namespace, you might need to wrap the specialization with the appropriate namespace declaration:
namespace MatlabParamParser {
template <> mxArray* wrap_array<rs2::texture_coordinate>(const rs2::texture_coordinate* var, size_t length) {
// Implementation
}
}
Please refer to the following MATLAB Documentation for further understanding:
Hope this helps!

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!