Error when compiling MATLAB MEX file, fails obviously on “__attribute__ ((visibility: (”default“)))”
I get these errors:
gcc: error: ((visibility: No such file or directory
gcc: error: ("default"))): No such file or directory
when compiling bar.c:
#include <mex.h>
void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] )
{
}
with CMakeLists.txt:
cmake_minimum_required( VERSION 3.12 )
# Project name and version
project( foo )
set( RFC_VERSION_MAJOR "0" )
set( RFC_VERSION_MINOR "2" )
find_package( Matlab QUIET REQUIRED COMPONENTS MX_LIBRARY )
# set up matlab libraries
include_directories( ${Matlab_INCLUDE_DIRS} )
# MEX function (MATLAB)
matlab_add_mex( NAME ${PROJECT_NAME} SRC bar.c OUTPUT_NAME foobar )
This seems to be a problem depending on the used toolchain, since other (older) compilers work.
- System: Red Hat Enterprise Linux Workstation, release 6.10 (Santiago)
- Kernel: Linux 2.6.32-754.9.1.el6.x86_64
- Desktop: GNOME 2.28.2
- Shell: tcsh 6.17.00 (Astron)
- CMake Version 3.13.3
- Compiler: gcc-5.3.0-4
- MATLAB: R2016b
Edit:
Disabling lines 1072ff in FindMatlab.cmake solves the problem in this (my) case:
set_target_properties(${${prefix}_NAME}
PROPERTIES
DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__ ((visibility (\"default\")))"
)
Edited by Andreas Martin