3

I am a beginner with using both the ada language, as well as using GPS. I can't seem to find any solid tutorials to help learn ada or GPS, but that's not my question.

I have tried various simple programs, like this one:

with Win32.crt.Math;
with Interfaces.C;

procedure sqrt is
X : Interfaces.C.Double;
begin
   X := Win32.crt.Math.sqrt(x => 4.0) ;
end sqrt;

I have tried others that are of similar simplicity and found other more complicated ones on the web, and I have really only gotten one to work.

Anyways, I get this error when I try to build:

gnatmake -d -PC:\Users\bqw3960\Desktop\GPS2012\2-two\sqrt.gpr sqrt.adb

gnatbind -x sqrt.ali

gnatlink -o c:\users\bqw3960\desktop\gps2012\2-two\sqrt.exe sqrt.ali

C:\GNAT\Bindings\Win32Ada\win32-crt-math.o(.text+0x1a):win32-crt-math.adb: undefined 

reference to `__imp__HUGE'

gnatlink: cannot call C:\GNAT\bin\gcc.exe

gnatmake: *** link failed.

[2013-06-13 10:53:18] process exited with status 4 (elapsed time: 00.51s)

I figure it is simple but I can't seem to figure it out.

I also sometimes get this when I try to compile after I change something for the first time:

gcc.exe: unrecognized option `-ws'
jam
  • 3,640
  • 5
  • 34
  • 50
Ben
  • 31
  • 2
  • Does a plain old [Hello World](http://en.wikipedia.org/wiki/Ada_%28programming_language%29#.22Hello.2C_world.21.22_in_Ada) program compile and link? It kinda looks like a problem with the installing of the Win32 bindings. – Marc C Jun 13 '13 at 15:27
  • yeah it does, i have gotten only one or two working programs, the hello world, and then a hello world with get(x) and a while loop to have the person guess, that is all i have managed to get working though – Ben Jun 13 '13 at 17:41
  • Get one of the older Ada 95 books used from Amazon, you get them for 5$ including shipping. For an indepth study you will need the book by Barnes about Ada 2005, no way around it. – Rick Mar 30 '14 at 06:05

2 Answers2

2

What does your sqrt.gpr say? I just tried this, and the gnatlink step said

gnatlink "C:\Documents and Settings\Simon\sqrt.ali" C:\GNAT\2012\lib\win32ada\static\libwin32ada.a -o "C:\Documents and Settings\Simon\sqrt.exe"

which is quite different from yours ... and worked.

My sqrt.gpr said

with "win32ada";
project Sqrt is
   for Main use ("sqrt.adb");
end Sqrt;
Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • mine looks the same, just without the first with line, i tried just adding it in there but it says "win32ada" is an unknown project file – Ben Jun 13 '13 at 17:45
  • I'm using Windows XP. When I installed `win32ada`, which I got from [the Libre web site](http://libre.adacore.com), it said that it couldn't find a working Ada compiler and asked me to browse to one's location, offering me `C:\GNATPRO`. I changed this to `C:\GNAT\2012` and it was installed under there (I see your equivalent would be `C:\GNAT` - your compiler binaries are at `C:\GNAT\bin`, mine are at `C:\GNAT\2012\bin`), including a `win32ada.gpr` in the place where GNAT expects to find it. There's no trace of a `Bindings\Win32Ada` directory; I wonder how yours got there? – Simon Wright Jun 13 '13 at 18:51
0

This is because your sqrt procedure is still running and you are trying to do both compile the solution and run your procedure at the same time. Halt execution of the program and then try compilation. It should work as expected.

Yadu SS
  • 21
  • 1