Can't use Dislin

37 views
Skip to first unread message

Abdelrahman Ahmad

unread,
Apr 19, 2021, 2:24:30 PM4/19/21
to dislin-users

Hello, I installed dislin using the .deb file version 11.4. My system is Ubuntu 20.04, I use g++ compiler. When I compile using g++, I get the following error main.cpp:(.text+0x2e): undefined reference to `Dislin::Dislin()'.

#include <iostream>
#include <cmath>
#include "/usr/local/dislin/discpp.h"

int main ()
{ int n = 100, i, ic;
double fpi = 3.1415926 / 180.0, step, x;
double xray[100], y1ray[100], y2ray[100];
Dislin g;

step = 360. / (n - 1);

for (i = 0; i < n; i++)
{ xray[i] = i * step;
x = xray[i] * fpi;
y1ray[i] = sin (x);
y2ray[i] = cos (x);
}

g.metafl ("cons");
g.scrmod ("revers");
g.disini ();
g.pagera ();
g.complx ();
g.axspos (450, 1800);
g.axslen (2200, 1200);

g.name ("X-axis", "x");
g.name ("Y-axis", "y");

g.labdig (-1, "x");
g.ticks (9, "x");
g.ticks (10, "y");

g.titlin ("Demonstration of CURVE", 1);
g.titlin ("SIN(X), COS(X)", 3);

ic=g.intrgb (0.95,0.95,0.95);
g.axsbgd (ic);

g.graf (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5);
g.setrgb (0.7, 0.7, 0.7);
g.grid (1, 1);

g.color ("fore");
g.height (50);
g.title ();

g.color ("red");
g.curve (xray, y1ray, n);
g.color ("green");
g.curve (xray, y2ray, n);
g.disfin ();
return 0;
}



Screenshot from 2021-04-19 19-29-40.png
main.cpp

Helmut Michels

unread,
Apr 20, 2021, 9:35:02 AM4/20/21
to dislin-users
Hi,

you have to compile with a Dislin header file and to link with a Dislin library. For example:

        g++  -c  -I/usr/local/dislin   main.cpp                         for compiling
        g++  main.o    -lm    -L/usr/local/dislin   -ldiscpp     for linking

You can replace g++  by clang++ in the commands above. I have tested it on Ubuntu 20.04.

With best regards,

Helmut
Reply all
Reply to author
Forward
0 new messages