bugGNU Octave - Bugs: bug #56945, mex command does not work, if...


bug #56945: mex command does not work, if external library needs to be linked

Submitted by:  None
Submitted on:  Tue 24 Sep 2019 03:20:20 PM UTC  
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  None
Status:  Works For Me Assigned to:  None
Originator Name:  MiB_Coder Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  5.1.0
Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 15 Oct 2019 09:02:07 AM UTC, comment #1: 

In the current shape, this bug report is useless, as those many (missing) answers may indicate ;-) Therefore I close this one as workarounds exist (see StackOverflow).

It can be opened at any time, if a minimal verifiable example is provided, where Octave can do better than now, or behaves incorrect. I think that no compiler can guess what libraries should be linked and where they might be located, if given without proper escaping.

Kai Torben Ohlhus <siko1056>
Project Member
Tue 24 Sep 2019 03:20:20 PM UTC, original submission:  

Please see the discussion here:


`mkoctfile` does not escape the arguments properly if they contain spaces and it does not like backslashes in Octave's own paths.
It creates the following two commands:

    g++ -c -I/release/mxe-octave-w64/usr/x86_64-w64-mingw32/include  -IC:\Octave\OCTAVE~1.0\\mingw64\include\octave-5.1.0\octave\.. -IC:\Octave\OCTAVE~1.0\\mingw64\include\octave-5.1.0\octave -IC:\Octave\OCTAVE~1.0\\mingw64\include   -fopenmp -g -O2   -I. "-IC:\Program Files (x86)\IVI Foundation\VISA\Winnt\Include"  -DMEX_DEBUG main.cpp -o C:\Octave\OCTAVE~1.0\tmp/oct-u4r15I.o
    g++ -IC:\Octave\OCTAVE~1.0\\mingw64\include\octave-5.1.0\octave\.. -IC:\Octave\OCTAVE~1.0\\mingw64\include\octave-5.1.0\octave -IC:\Octave\OCTAVE~1.0\\mingw64\include   -fopenmp -g -O2 -shared -Wl,-rpath-link,/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/qt5/lib -Wl,--export-all-symbols  -o main.mex  C:\Octave\OCTAVE~1.0\tmp/oct-u4r15I.o  -lvisa64.lib  -LC:\Program Files (x86)\IVI Foundation\VISA\Winnt\lib_x64\msc -LC:\Octave\OCTAVE~1.0\\mingw64\lib\octave\5.1.0 -LC:\Octave\OCTAVE~1.0\\mingw64\lib -LC:\Octave\OCTAVE~1.0\\mingw64\lib\octave\5.1.0 -loctinterp -loctave  -Wl,-rpath-link,/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/qt5/lib -Wl,--export-all-symbols

When I change it to the following:

  - replace `\` with `/`
  - specify the library name without .lib extension
  - escape `-LC:\Program Files...` to `"-LC:\Program Files..."`

<!-- -->

    g++ -c -I/release/mxe-octave-w64/usr/x86_64-w64-mingw32/include  -IC:/Octave/OCTAVE~1.0//mingw64/include/octave-5.1.0/octave/.. -IC:/Octave/OCTAVE~1.0//mingw64/include/octave-5.1.0/octave -IC:/Octave/OCTAVE~1.0//mingw64/include   -fopenmp -g -O2   -I. "-IC:/Program Files (x86)/IVI Foundation/VISA/Winnt/Include"  -DMEX_DEBUG main.cpp -o C:/Octave/OCTAVE~1.0/tmp/oct-u4r15I.o 
    g++ -IC:/Octave/OCTAVE~1.0//mingw64/include/octave-5.1.0/octave/.. -IC:/Octave/OCTAVE~1.0//mingw64/include/octave-5.1.0/octave -IC:/Octave/OCTAVE~1.0//mingw64/include   -fopenmp -g -O2 -shared -Wl,-rpath-link,/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/qt5/lib -Wl,--export-all-symbols  -o main.mex  C:/Octave/OCTAVE~1.0/tmp/oct-u4r15I.o "-LC:/Program Files (x86)/IVI Foundation/VISA/Winnt/lib_x64/msc" -lvisa64 -LC:/Octave/OCTAVE~1.0//mingw64/lib/octave/5.1.0 -LC:/Octave/OCTAVE~1.0//mingw64/lib -LC:/Octave/OCTAVE~1.0//mingw64/lib/octave/5.1.0 -loctinterp -loctave  -Wl,-rpath-link,/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/lib -L/release/mxe-octave-w64/usr/x86_64-w64-mingw32/qt5/lib -Wl,--export-all-symbols

It will compile without error.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-10-15 siko1056 CategoryNone => Octave Function
        Severity3 - Normal => 2 - Minor
        Priority5 - Normal => 3 - Low
        StatusNone => Works For Me
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.5