[GiNaC-list] failing to compile expressions to C function pointers

Marian Anghel manghel at lanl.gov
Mon Nov 19 20:45:55 CET 2007

I'm trying to implement the example that shows how to define a GiNaC
expression and to compile an associated C code. My implementation of 
the 5.15.3 example in ginac_tutorial.pdf is as  follows:

#include <iostream>
#include <ginac/ginac.h>
#include <iterator>
#include <numeric>

using namespace std;
using namespace GiNaC;

ex HermitePoly(const symbol & x, int n)
  ex HKer=exp(-pow(x, 2));
  // uses the identity H_n(x) == (-1)^n exp(x^2) (d/dx)^n exp(-x^2)
  return normal(pow(-1, n) * diff(HKer, x, n) / HKer);

int main()

  try {

    symbol x("x");
    ex myexpr = HermitePoly(x,2); ;
    FUNCP_1P fp;
    compile_ex(myexpr, x, fp);
    cout << fp(1) << endl;

  } catch(exception &p){
    cerr << p.what() << endl;

  return 0;


1) The code compiles but the attempt to execute it gives this error:

excompiler::link_so_file: could not open compiled module!

2) I'm not sure that my installation of GiNaC went right. I'm not very
skilled with software installation and I did it in my home directory
using the prefix configuration option. All examples tested thus far have
worked correctly except for this one. 

3) I'm not sure about the relationship to the error I'm getting but I'll
mention this anyway: The doc/examples directory does not have any of the
compile[123].cpp examples mentioned in ginac-examples.pdf. It has
instead the archive1.cpp example.

I'll appreciate your help in fixing this problem.


Marian Anghel

More information about the GiNaC-list mailing list