Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4,103
    • Issues 4,103
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #19279
Closed
Open
Issue created May 21, 2019 by Andreas Martin@AndreasMartin72

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 May 21, 2019 by Andreas Martin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking