Search code examples
macosquantum-computingqcl

Error trying to install QCL (Quantum Computation Language) on Mac 10.11


I am trying to install QCL-0.6.4 from this source, but I keep getting errors, when I try it with the make command in the terminal.

I came along this thread about installing QCL on OSX, but when trying to adjust the Makefile I always come across this errors:

extern.cc:84:18: error: variable length array of non-POD element type     'tComplex'
  (aka 'complex<double>')
 tComplex u[dim][dim];
             ^
extern.cc:193:9: error: variable length array of non-POD element type 'term'
 term t[dim];
    ^
extern.cc:224:9: error: variable length array of non-POD element type 'term'
 term t[dim];

Any help on this would be highly appreciated.


Solution

  • There are a few issues at play here which you need to overcome to get this compiling on OSX. My instructions below assume that you are running on El Capitan (10.11.1 in my instance), but you may get some milage out of them for different versions.

    Firstly, Xcode currently uses Apple's LLVM Compiler as the default C++ compiler. However, this doesn't support some of GCC's extensions, such as support for non-POD variable length arrays.

    To get around this, I installed and compile with GCC: if you haven't already, install Homebrew, and then install the latest GCC compiler with:

    $ brew install gcc
    

    At the time of writing, this will install GCC v5.2.0. That should fix your initial problem, but you will instantly hit others!

    The next issue is that the included libqc.a will need recompiling for x86_64. So you will need to modify the file <base_dir>/qc/Makefile with the following changes:

    ...
    # Add:
    CXX = /usr/local/Cellar/gcc/5.2.0/bin/g++-5
    CXXFLAGS = $(ARCHOPT) -c -pedantic -Wall $(DEBUG) $(PRGOPT)
    ...
    

    Then rebuild libqc.a:

    $ cd qc; make clean; make
    

    If all goes well, you should have a shiny new libqc.a.

    Finally, modify the main Makefile <base_dir>/Makefile with the following changes:

    ...
    # Comment out:
    #PLOPT = -DQCL_PLOT
    #PLLIB = -L/usr/X11/lib -lplotter
    ...
    # Comment out:
    #RLOPT = -DQCL_USE_READLINE
    #RLLIB = -lreadline
    #RLLIB = -lreadline -lncurses
    ...
    # Comment out:
    #CXX = g++
    #CPP = $(CC) -E
    #CXXFLAGS = -c $(ARCHOPT) $(DEBUG) $(PLOPT) $(RLOPT) $(IRQOPT) $(ENCOPT) -I$(QCDIR) -DDEF_INCLUDE_PATH="\"$(QCLDIR)\""
    #LDFLAGS = $(ARCHOPT) -L$(QCDIR) $(DEBUG) $(PLLIB) -lm -lfl -lqc $(RLLIB) 
    
    # Add:
    CXX = /usr/local/Cellar/gcc/5.2.0/bin/g++-5
    CPP = $(CC) -E
    CXXFLAGS = -c $(ARCHOPT) $(DEBUG) $(PLOPT) $(RLOPT) $(IRQOPT) $(ENCOPT) -I$(QCDIR) -DDEF_INCLUDE_PATH="\"$(QCLDIR)\""
    LDFLAGS = $(ARCHOPT) -L$(QCDIR) $(DEBUG) $(PLLIB) -lm -ll -lqc $(RLLIB) -lc++
    ...
    

    This should now allow you to build the main application as per the instructions:

    $ make clean; make; make install