Help with mkoctfile

This is my first post, so please bear with me. I’m fairly experient in working with Octave, and have done several scripts with it. My problem is that now I need to integrate Octave with C++ and I can’t seen to make it work. I know I have to use OctFiles, and that I have to use mkoctfile function, but it simply does not work! I can’t even make the " A.1.1 Getting Started with Oct-Files" example to work. Here is my description of the problem:

Problem description

  • I created a .cpp file using the code provided by the afore mentioned example (the hello world example), let’s just call it “test.cpp” for now;

  • In octave, I set my current directory to the folder I saved the test.cpp file;

  • In command window, I try to use “mkoctfile test.cpp” exactly as the guidelines directs;

  • Result: I get the following error:

    g++: error: Octave\Octave-6.2.0\mingw64\ /include: No such file or director
    error: mkoctfile: building exited with failure status

  • Just a comment: notice " \ " and " / "before “include”? Is this normal? The space between then does not exist. For some reason this forum “erases” the " \ " automatically if it is not followed by some other character.

My system

  • OS: Windows 10 Home (version 20H2) build 19042.928
  • Octave version: 6.2.0 freshly installed
  • Installation method: Downloaded and installed “octave-6.2.0-w64-installer.exe” from

By default, Octave 6 tries to convert its installation path to short filename format on Windows to work around potential issues with spaces in paths.
The support for short file names seems to be deactivated on some partitions for some users which causes that workaround to fail.

To be able to tell if this is the reason for what you are seeing, could you please answer the following questions?

Where did you install Octave (complete path including drive letter)?
What does OCTAVE_HOME return for you in Octave?
What does the following command return for you in Octave?

system(sprintf('dir /x "%s/.."', OCTAVE_HOME))
1 Like

Here you go:

C:\Program Files\GNU Octave\Octave-6.2.0

ans = C:\PROGRA~1\GNU Octave\Octave-6.2.0\mingw64
 system(sprintf('dir /x "%s/.."', OCTAVE_HOME))
 Volume in drive C is OS
 Volume Serial Number is 9600-3A7D

 Directory of C:\PROGRA~1\GNU Octave\Octave-6.2.0

04/21/2021  10:00 AM    <DIR>                       .
04/21/2021  10:00 AM    <DIR>                       ..
04/21/2021  10:00 AM    <DIR>                       clang32
04/21/2021  10:00 AM    <DIR>                       clang64
02/19/2021  10:51 PM             1,148              cmdshell.bat
04/21/2021  09:58 AM    <DIR>                       dev
04/21/2021  10:00 AM    <DIR>                       etc
02/19/2021  10:51 PM               416              fc_update.bat
02/19/2021  10:51 PM                13              HG-ID
04/21/2021  09:58 AM    <DIR>                       home
04/21/2021  09:58 AM    <DIR>                       mingw32
04/21/2021  09:58 AM    <DIR>                       mingw64
04/21/2021  09:58 AM    <DIR>                       notepad++
02/19/2021  10:51 PM             2,273              octave-firsttime.vbs
02/19/2021  10:51 PM             2,629              octave.vbs
04/21/2021  09:55 AM    <DIR>                       opt
02/19/2021  10:51 PM             1,394              post-install.bat
02/19/2021  10:51 PM             2,556              README.html
04/21/2021  09:55 AM    <DIR>                       tmp
04/21/2021  10:00 AM           181,389              uninstall.exe
04/21/2021  10:00 AM    <DIR>                       usr
04/21/2021  10:00 AM    <DIR>                       var
               8 File(s)        191,818 bytes
              14 Dir(s)  35,213,725,696 bytes free
ans = 0

Hu. So it looks like it (correctly) shortened the “Program Files” part of the path. But it didn’t shorten “GNU Octave”.
Also, it looks like the file system doesn’t store short file names for some of the files that don’t fit into the 8.3 naming scheme.

Just to be sure: Could you please also show what the following command returns for you in Octave?

 system('dir /x "C:\Program Files\GNU*"')
 Volume in drive C is OS
 Volume Serial Number is 9600-3A7D

 Directory of C:\Program Files

04/21/2021  10:00 AM               388              GNU
04/21/2021  09:55 AM    <DIR>                       GNU Octave
               1 File(s)            388 bytes
               1 Dir(s)  33,907,286,016 bytes free
ans = 0

It looks like at some point short file names have been disabled for that partition. When the Program Files folder was created, short file names seem to have still been activated for the C: partition. But I’d guess that happens very early on when Windows is installed. Fwiw, short file names could have been deactivated on your device ever since you got it.
This seems to become more commonplace (because it could improve file system performance).
Just out of interest: What manufacturer is your PC/laptop or where did you buy it?

Afaict, mkoctfile with file systems like yours will be supported in Octave 7 (which is still some time off currently).

For the time being, please try to uninstall Octave and install it again. During installation, please change the destination to something that doesn’t have spaces in its path. Like e.g. C:\Octave\Octave-6.2.0 or something similar.

Does using mkoctfile work after that?

1 Like

I feared we would have to resort to that. Well, it worked after I uninstalled and reinstalled in a new path, as you instructed (C:\Octave\Octave-6.2.0), but I can’t shake that feeling of dumbness…

Welp, thank you so much for your help!

Btw my laptop is a DELL inspiron 7000, I bought it online (official store) with Windows 10 Home license.

I feel it is unfair to the developers to complain too much about this, as Octave is open source and it helps me A LOT, so thank you (developers) for the hard work!

After mkoctfile worked edit:
Ok, now that the function is working, bilions of new questions are popping! Should I just continue posting questions here or should I create a new post for each new question?