I am running a test code using PLplot as follows:
with PLplot_Auxiliary, PLplot_Standard;
use PLplot_Auxiliary, PLplot_Standard;
procedure xstandard00a is
x, y : Real_Vector(0 .. 100);
x_Min, y_Min : Long_Float := 0.0;
x_Max : Long_Float := 1.0;
y_Max : Long_Float := 100.0;
begin
-- Prepare data to be plotted.
for i in x'range loop
x(i) := Long_Float(i) / Long_Float(x'length - 1);
y(i) := y_Max * x(i)**2;
end loop;
-- Parse and process command line arguments.
Parse_Command_Line_Arguments(Parse_Full);
-- Initialize plplot.
Initialize_PLplot;
-- Create a labelled box to hold the plot.
Set_Environment(x_Min, x_Max, y_Min, y_Max,
Justification => Not_Justified,
Axis_Style => Linear_Box_Plus);
Write_Labels
(X_Label => "x",
Y_Label => "y=100 x#u2#d",
Title_Label => "Simple PLplot demo of a 2D line plot");
-- Plot the data that was prepared above.
Draw_Curve(x, y);
-- Close PLplot library.
End_PLplot;
end xstandard00a;
It does not build in geany using the command gnatmake "%e"
and does not compile by command gcc -Wall -c "%f"
.
It gives me the error:
xstandard00a.adb:20:05: file "plplot_auxiliary.ads" not found
xstandard00a.adb:21:05: file "plplot_standard.ads" not found
Obviously I have to link to libraries. The *.ali
files of PLplot are located at /usr/lib64/ada/adalib/plplotada
.
How do I link with build command gnatmake
, or how do I add extra code in xstandard00a.adb
to find those PLplot libraries *.ali
?
Update:
I run Make file provided with examples (xstandard00a.adb) and it compiled successfully. I opened make file to see flags it uses to compile. I put those flags exactly and recompile another example that looks like xstanrd00a.adb and it failed to find libraries. Obviously there is something else besides flags used by gnat make. I am missing something. The Make file is written as follows,
SHELL = /bin/bash
GNAT_EXECUTABLE_BUILDER = /usr/bin/gnatmake
"-aI/usr/share/ada/adainclude/plplotada" "-aL/usr/lib64/ada/adalib /plplotada"
EXEEXT =
PKG_CONFIG_ENV = PKG_CONFIG_PATH="/usr/lib64/pkgconfig::/usr/lib64/pkgconfig:/usr/share/pkgconfig"
install_tree_ada_RPATHCMD =
EXECUTABLES_list = \
xtraditional00a$(EXEEXT)
all: $(EXECUTABLES_list)
clean:
rm -f $(EXECUTABLES_list) *.ali *.o
# target_link_libraries( plplotada plplot)
# Due to command-line limitations of gnatmake cannot continue (by trailing \)
# anything after -cargs below.
.adb$(EXEEXT):
$(GNAT_EXECUTABLE_BUILDER) $< \
-cargs $(shell $(PKG_CONFIG_ENV) pkg-config --cflags plplot-ada plplot) -largs $(install_tree_ada_RPATHCMD) $(shell $(PKG_CONFIG_ENV) pkg- config --libs plplot-ada plplot)
.SUFFIXES: .adb $(EXEEXT)
What I am missing in compilation/linking libraries? I tried the gpr method using gnatmake -P and still failed to link. So far the only method that works for me is Make file. However, I want to compile manually to figure out how this thing works. What I wrote in build command in Geany IDE was this:
gnatmake "%e" -aI/usr/share/ada/adainclude/plplotada -aL/usr/lib64/ada/adalib/plplotada
"%e" refers to any adb file in IDE and in my case simpleplot.adb which is basically xstandard00a.adb
-Ilib_dir
to gnatmake. Some people like to make things more complicated for themselves by putting the various kinds of files in different directories. If you or the PL Plot installer have done that, then getting it to work with gnatmake will be more complicated, of course. – Jeffrey R. Carter