Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If the title to this question seems a bit vague, I am sorry. But I wasn't sure how to distill what I am attempting to do into a single sentence.

A few weeks back I learned that I could build and install recent releases of Octave on an Ubuntu 12.04 system by following the steps below.

  1. Install the tools needed to compile, link, and run octave. For Ubuntu the commands below have worked for me.

    sudo apt-get build-dep octave3.2
    sudo apt-get install build-essential gnuplot gtk2-engines-pixbuf
    sudo apt-get install libfontconfig-dev bison
  2. Next, download the source code for an Octave release from the Gnu Project Archives for Octave and unpack the archive into a folder on your system.

  3. Use the commands below to build, check, and install octave.

     make check
     sudo make install

Unfortunately it turns out that the above builds an Octave that contains all the debugging symbol tables. The object files alone are huge taking up around 1.7 GB.

The current Octave documentation suggests

To compile without debugging symbols try the command
instead of just make.

However, when I tried this it did not work. The -g option was still used for the compiles. For the heck of it I instead tried ./configure CFLAGS=-O CXXFLAGS=-O and this did work. (Instead of ~1.7GB the result of the build now takes up around 253MB).

My questions are

  1. Is this actually the correct (recommended?) method to use to compile Octave without debugging symbols (i.e. without -g)?
  2. How would I compile Octave so it uses x86_64 rather than x86?
    Note: I am not asking how to compile Octave to use the (experimental) 64-bit integers for array dimensions. I just want to allow the compiler to use the extra registers and word sizes available when an app runs in 64-bit mode.
  3. Is a (more) complete list available for the directives used with the Octave Makefile?
    I have only seen make, make check, and make install documented. But apparently make distclean is also allowed. (It removes the compilation results so you can do a complete rebuild of everything.)
    I'm wondering what else might be available.

FWIW, I have tried using
./configure CFLAGS="-O3 -mtune=core2 -m64" CXXFLAGS="-O3 -mtune=core2 -m64"
and, surprisingly, it not only appeared to build, but also ran and passed the make check tests.

But of course that's not the same thing as saying it actually "works". Is there a recommended way to enable Octave to run as an x86_64 app?

I have also tried looking inside the Octave Makefile to see if I could decipher what command line directives it accepts. I got nowhere. I have not a single clue as to how that Makefile does whatever it is that it does.

share|improve this question

It depends on your version of gcc, your hardware, your distribution, and a lot of other things. Typically, your Linux distribution provider would have done that research for you and used those options when building your package. Distributions, however, try to make things work with most hardware and user expectations. I find the most customization without having to go to too much trouble with Gentoo. Linux from scratch or rolling your own distribution is a lot of work. I have a Gentoo installation with 32-bit emulation turned off in the kernel.

From Gentoo Optimization Guide, it's best to use -O2 instead of -O3

-O3: This is the highest level of optimization possible, and also the riskiest. It will take a longer time to compile your code with this option, and in fact it should not be used system-wide with gcc 4.x. The behavior of gcc has changed significantly since version 3.x. In 3.x, -O3 has been shown to lead to marginally faster execution times over -O2, but this is no longer the case with gcc 4.x. Compiling all your packages with -O3 will result in larger binaries that require more memory, and will significantly increase the odds of compilation failure or unexpected program behavior (including errors). The downsides outweigh the benefits; remember the principle of diminishing returns. Using -O3 is not recommended for gcc 4.x.

-mtune=core2 is ok if you're sure that's the best choice for your processor. I personally like -march=native instead. See Gentoo Safe CFlags

GCC 4.2 introduces a new -march option, -march=native, which automatically detects the features your CPU supports and sets the options appropriately. If you have an Intel or AMD CPU and are using >=sys-devel/gcc-4.2.3, using -march=native is recommended.

-m64 is a processor option and should be automatically set by -mtune=core2 or -march=native. See GCC i386 and x86-64 Options.

Disclaimer: You do not have to switch to Gentoo in order to use their advice for compiling from source.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.