DougT
DougT

Reputation: 231

SymbolicC++ error on linux

I am trying to install SymbolicC++ from SymbolicC++3-3.35-ac.tar on Ubuntu 15.10. I did a ./configure, make, sudo make install with no errors.

I tried to compile the following with g++ test1.cpp -lsymbolicc++:

#include <iostream>
#include "symbolicc++.h" 
using namespace std;

int main(void)
{
  Symbolic x("x");
  cout << integrate(x+1, x) <<endl;       // => 1/2*x^(2)+x
  Symbolic y("y");
  cout << df(y, x) << endl;               // => 0
  cout << df(y[x], x) << endl;            // => df(y[x],x)
  cout << df(exp(cos(y[x])), x) << endl ; 
                             // => -sin(y[x])*df(y[x],x)*e^cos(y[x])
  return 0;
}

This code was from the Wikipedia article on SymbolicC++

I get the following errors:

doug@doug-Z170X-UD5:~/books_computerAlgebraSys$ g++ test1.cpp -lsymbolicc++
/usr/local/lib/libsymbolicc++.so: undefined reference to `Number<double>::Number(double const&)'
/usr/local/lib/libsymbolicc++.so: undefined reference to `Number<int>::Number(int const&)'
collect2: error: ld returned 1 exit status

Upvotes: 2

Views: 682

Answers (1)

EmDroid
EmDroid

Reputation: 6046

Try to add "-fno-elide-constructors" to the g++ command line:

g++ test1.cpp -lsymbolicc++ -fno-elide-constructors

From the project main page http://issc.uj.ac.za/symbolic/symbolic.html:

Users of SymbolicC++ with GCC on 64-bit may need to use the -fno-elide-constructors flag.

Edit: But that seems to apply more to the header-only version of the library (there are two versions, header-only and the Autoconf library version). But I tried with your example and the AC library and for me it builds and works fine even without the "-fno-elide-constructors" (Ubuntu 14.04 64-bit, g++ 4.8.4).

Edit 2: To wrap up, it seems that the library autoconf version does not work on every machine for some reason. With the header-only library, the -fno-elide-constructors flag needs to be used with 64-bit, and the -I option to point to the headers location (where the library is unpacked):

g++ test1.cpp -fno-elide-constructors -I<path_to_headers>

Upvotes: 2

Related Questions