3

The -f command-line argument to mex allows to specify the location of the mexopts.sh that we wish to use. But is there a way to tell Matlab to ignore mexopts.sh? In order to compile a specific MEX file I need to specify CC, CFLAGS, etc., directly on the command line when invoking mex. Values already given in mexopts.sh cause a conflict and cause mex to fail.

Thanks!

Dominique
  • 299
  • 2
  • 14
  • Why not specify an empty mexopts.sh file? – Daniel Williams Apr 23 '13 at 20:49
  • Because this is part of software that will be distributed. Are you suggesting we ship an empty `mexopts.sh`? I guess that's a possibility. – Dominique Apr 23 '13 at 20:52
  • You could just ship a makefile that invokes the compiler directly and creates a shared library with the appropriate `mexext`. After all, there's nothing special about a mex file other than the predefined `mexFunction` entry point. This is what I'd prefer unless I was targeting multiple compilers / OSes, in which case it's nice to have the `mex` function manage the details. – Praetorian Apr 23 '13 at 20:55
  • That's precisely what we're doing but it seems that `mex` is grabbing options from the default `mexopts.sh` that are not specified on the command line. I can tell because it tries to use different C flags. – Dominique Apr 23 '13 at 21:02
  • 1
    @Dominique I meant ship a makefile that calls GCC (or whatever compiler you're using) directly. Don't call the `mex` function, that will read options for the currently configured compiler from *mexopts.sh*. You can create a mex file yourself by having GCC create a shared library (with the correct extension) and exporting `mexFunction`. – Praetorian Apr 23 '13 at 21:19
  • @Dominique You have any success with this? Would you be against just specifying the options you don't want with `COMPFLAGS = ''` or something along these lines? Also, did specifying an empty .sh file and using `-f` to point to it work as per Daniel's suggestion? – JustinBlaber Apr 23 '13 at 23:33

0 Answers0