Having a problem building with win32ada

Jump to:

Sponsored Links

Next

1. Pascal ranges"(see below)" < XXXX@XXXXX.COM > writes:
> Often, yes, it is, but there are cases where one wants to model in Pascal a
> similar kind of relationship as exists between Integer, Natural and
> Positive, but for a more restricted range.
I agree.
>.. The need for these closely
> related subranges is rather smaller in Ada, e.g. thanks to array attributes
> such as 'First and 'Last.
I don't understand why you say "need...rather smaller" here.
I often have two subtypes of the same type, one for counting
how many there are (0..N), and one for indexing into an array
of them (1..N). Like this:
type Blah_Index is range 1..N;
subtype Blah_Count is Blah_Index'Base range 0..Blah_Index'Last;
- Bob

2. TASH (TclAdaSHell) futuresWhile working on using TASH on a recent Linux system we found a
problem with Tcl/Tk releases later than 8.4 (for example, Ubuntu 8.04
has Tcl/Tk 8.5).
TASH has three levels of implementation: very thin (a binding to the
C headers using pragma Import, in eg unit Tcl), thin (using more Ada-
like constructs, in eg Tcl.Ada) and thick (exporting Tcl facilities
such as file handling and sparse arrays, in eg Tash.Arrays).
Unfortunately, the thick binding relies on C interfaces that were
never intended to be public and have been hidden (made private) in Tcl/
Tk 8.5 and later, and there doesn't seem to be a way round this
without a lot of work.
Are there any TASH users out there who have strong views on this?
whose projects depend on Tash.* facilities? If so, comments please,
here or at SourceForge (https://sourceforge.net/forum/forum.php?
forum_id=558610).

Having a problem building with win32ada

by John McCabe » Sat, 06 Mar 2010 20:41:56 GMT

Hi Guys
Further to my message the other day, I've downloaded the GPL 2009
version of GNAT with the Win32Ada bindings and I'm trying to do
something really simple at the moment, namely, get the number of input
and output midi devices on my system through Win32.Mmsystem.
The code I'm using is at the bottom of this message.
I've created a project in GPS (and other things) but so far have been
unsuccessful in building it and I can't see any obvious reason why.
I've set the project in GPR to reference the [known] win32ada library
and, as far as I can see, there's nothing much different to the
example "connect" application that comes with win32ada however when I
try to build it, I get this (compilation is fine, just linking doesn't
work):
gnatmake -d -PC:\\AdaProjects\\TestMidiDevs\\testmididevs.gpr
MidiDevs.adb
gnatbind -I- -x C:\AdaProjects\TestMidiDevs\mididevs.ali
gnatlink C:\AdaProjects\TestMidiDevs\mididevs.ali
-LC:\GNAT\2009\lib\win32ada\ -lwin32ada -o
C:\AdaProjects\TestMidiDevs\mididevs.exe
c:\adaprojects\testmididevs\MidiDevs.o:MidiDevs.adb:(.text+0x2d):
undefined reference to `_midiInGetNumDevs@0'
c:\adaprojects\testmididevs\MidiDevs.o:MidiDevs.adb:(.text+0x7d):
undefined reference to `_midiOutGetNumDevs@0'
collect2: ld returned 1 exit status
gnatlink: error when calling C:\GNAT\2009\bin\gcc.exe
gnatmake: *** link failed.
[2010-03-05 11:36:33] process exited with status 4 (elapsed time:
02.98s)
Now that says to me that those functions don't exist in the bunch of
libraries that are being linked in. Is there something I need to do to
rebuils the libwin32ada.a? When I installed it I went for the
automatic configuration option and it looked like it was being built
there.
Sorry if this seems like a stupid question but does anyone know what
I've done wrong or what's missing? As I mentioned, it's been a while
since I used Ada in anger so while I'm ok with syntax and semantics,
the subtleties of building something using GPS (tried it in Gnatbench
on Eclipse too) against an existing library are a bit beyond me and
it's difficult to track down much information on that.
Thanks
John
===========
testmididevs.gpr
===========
with "win32ada.gpr";
project TestMidiDevs is
for Source_Dirs use (".");
package Compiler is
for Default_Switches ("ada") use ("-gnat05");
end Compiler;
for Main use ("MidiDevs.adb");
end TestMidiDevs;
==========
MidiDevs.adb
==========
with Ada.Text_IO;
with Win32;
with Win32.Mmsystem;
procedure MidiDevs is
package UINTText_IO is new Ada.Text_IO.Modular_IO(Win32.UINT);
begin
Ada.Text_IO.Put("There are ");
UINTText_IO.Put(Win32.Mmsystem.midiInGetNumDevs);
Ada.Text_IO.Put_Line(" input devices");
Ada.Text_IO.Put("There are ");
UINTText_IO.Put(Win32.Mmsystem.midiOutGetNumDevs);
Ada.Text_IO.Put_Line(" output devices");
end MidiDevs;

Re: Having a problem building with win32ada

by Dmitry A. Kazakov » Sat, 06 Mar 2010 22:12:52 GMT

You have to link against Winmm.lib change the gpr file as follows:
with "win32ada.gpr";
project TestMidiDevs is
for Source_Dirs use (".");
for Source_Files use ("MidiDevs.adb");
for Main use ("MidiDevs.adb");
package Compiler is
for Default_Switches ("ada") use ("-gnat05");
end Compiler;
package Linker is
for Default_Switches ("ada") use ("-lwinmm");
end Linker;
end TestMidiDevs;
--
Regards,
Dmitry A. Kazakov
http://www.**--****.com/

Re: Having a problem building with win32ada

by John McCabe » Sat, 06 Mar 2010 23:03:31 GMT

On Fri, 5 Mar 2010 14:12:52 +0100, "Dmitry A. Kazakov"
<..snip..>
Dmitry, you're a star. Thanks for that.
As an aside, now that I've done that, and it works nicely thank you, I
looked at my project properties in GPS and can see no difference to
any of the settings in there. Do you know if there's a way to add that
sort of thing in GPS?
Alternatively, I couldn't see any obvious way to add that sort of
thing in Gnatbench 2.3.x (GPL). Any ideas on that too? I've
importedthe Win32Ada project in to Eclipse and se it as referenced by
the MidiDevs one, but I get Win32 is undefined etc so it's not even
seeing win32.ads!

Re: Having a problem building with win32ada

by John McCabe » Sat, 06 Mar 2010 23:27:38 GMT

On Fri, 05 Mar 2010 14:03:31 +0000, John McCabe
Ah - I've just found it now. It's in a little tiny edit box at the
bottom of the "Ada Linker" tab of the "Switches" page on the project
properties. A completely unlabelled edit box that gives no hint of its
purpose!
Is it just me or is GPS really crap?

Re: Having a problem building with win32ada

by John McCabe » Sat, 06 Mar 2010 23:35:49 GMT

On Fri, 05 Mar 2010 14:03:31 +0000, John McCabe
Ok - using the same technique (editing the GPR file) I've now managed
to get the same project working in Eclipse/GNATBench.
Now to see if I can get anywhere with Netbeans!

Re: Having a problem building with win32ada

by J-P. Rosen » Sun, 07 Mar 2010 00:41:10 GMT

John McCabe a rit :
The GUI is just sugar for building the command line. That little box
shows you the options that will be selected according to the boxes you
ticked above. In addition (and it is a nice escape for unusual options),
you can edit that string to add whatever options are not available from
the GUI.
--
---------------------------------------------------------
J-P. Rosen ( XXXX@XXXXX.COM )
Visit Adalog's web site at http://www.**--****.com/

Re: Having a problem building with win32ada

by Simon Wright » Sun, 07 Mar 2010 05:24:17 GMT

John McCabe < XXXX@XXXXX.COM > writes:
GPS is a work in progress, I guess.
A colleague had exactly the same problem, it took a moment or two for
inspiration to strike.
Personally I prefer Emacs ada-mode except for debugging, when GPS is
pretty neat.

Re: Having a problem building with win32ada

by Dmitry A. Kazakov » Tue, 09 Mar 2010 20:52:28 GMT

You didn't see the first versions of GPS! Presently GPS is quite good. OK,
the de{*filter*} is a total crap, but it is not GPS's fault, but the gdb's one.
Project setting dialog is unusable, but nobody would create gpr files using
it anyway. I would just throw it away in AdaCore's place. GPS also has some
problems, which are rather to addressed to GTK.
Eclipse is certainly much worse than GPS, slow, ugly, unstable. I hope
AdaCore will abandon GNATBench and concentrate all efforts on GPS.
--
Regards,
Dmitry A. Kazakov
http://www.**--****.com/

Re: Having a problem building with win32ada

by John McCabe » Tue, 09 Mar 2010 21:28:11 GMT

On Mon, 8 Mar 2010 12:52:28 +0100, "Dmitry A. Kazakov"
Oh!
I would tend towards the opposite. I think they'd be better off
spending their time building good quality plug-ins for more mature and
more widely used IDEs (e.g. Eclipse, Microsoft Visual Studio) than
developing their own proprietary one. It's going to take a lot of
effort to get GPS to the point where someone says "wow" when they see
it. I know it has some great features, but....
Anyway - this isn't really the place to discuss the IDE but thanks for
your comments.

Re: Having a problem building with win32ada

Thought I might as well add it to this thread, but I'm now having a
slight problem running with Win32Ada.

The basis of the code I'm using is in my "please review my code"
thread.

Essentially I've got the code shown below the double dashed line
(well, that's most of it).

When I run it, the Read_And_Print_Patches call _before_ outputting the
output device information is fine, but the same call _after_
outputting the output device information fails. Sometimes it just
prints the "1" prior to the Ada.Text_IO.Open call, and sometimes I get
PROGRAM_ERROR EXCEPTION_ACCESS_VIOLATION.

Now, if I change the declarations of Midi_In_Caps and Midi_Out_Caps
to:

and use 'Unchecked_Access in the calls to midiInGetDevCaps and
midiOutGetDevCaps for those objects (and dispose of the Free calls) it
seems to work ok. That sounds like some memory isn't being allocated
properly somehow. I can't see that I'm doing anything wrong but if you
can please let me know.

One thing I noticed though is that in mmsystem.h (in the
i686-pc-mingw32 folder) the declaration of MIDIINCAPS (well,
MIDIINCAPSA as it's non-Unicode) is:

procedure Free is new
Ada.Unchecked_Conversion(Win32.Mmsystem.LPMIDIINCAPS,
Win32.Mmsystem.MIDIINCAPS);
procedure Free is new
Ada.Unchecked_Conversion(Win32.Mmsystem.LPMIDIOUTCAPS,
Win32.Mmsystem.MIDIOUTCAPS);

package UINT_Text_IO is new
Ada.Text_IO.Modular_IO(Win32.UINT);
package MM_Text_IO is new
Ada.Text_IO.Modular_IO(Win32.Mmsystem.MMRESULT);

Re: Having a problem building with win32ada

by John McCabe » Thu, 11 Mar 2010 06:37:15 GMT

Couple of corrections....
1) I've put Unchecked_Conversion where it should be
Unchecked_Deallocation. Replace:
With
procedure Free is new
Ada.Unchecked_Deallocation(Win32.Mmsystem.MIDIINCAPS,
Win32.Mmsystem.LPMIDIINCAPS);
procedure Free is new
Ada.Unchecked_Deallocation(Win32.Mmsystem.MIDIOUTCAPS,
Win32.Mmsystem.LPMIDIOUTCAPS);
2) In face, the replacing with aliased Win32.Mmsystem.MIDIINCAPS etc
and use of Unchecked_Access DOESN'T WORK. It stops the file open from
failing, but the calls to midiIn/OutGetDevCaps return MMRESULT value
11 whish is Invalid Parameter.
Ah well.
I've done some more searching, and it looks to me like basically the
Win32Ada binding that AdaCore are allowing people to download are a
minimum of 11 years old. Apparently the last intermetrics version
(3.0) was released in 1999. The win32-mmsystem.ads has an Intermetrics
copyright date of 1995.
This is rather unfortunate. I'd hope this would be very useful for
what I wanted to do but, to be honest, it looks like the idea is
doomed as I really don't want to have to re-create a whole set of
Win32 Ada bindings based on the existing MinGW versions of these files
(that also appear to be out of date compared to the definitions of the
types you can find on Microsoft's website).
Disappointing.
John

Re: Having a problem building with win32ada

by tmoran » Thu, 11 Mar 2010 11:32:30 GMT

> One thing I noticed though is that in mmsystem.h (in the
Looking at an mmsystem.h dated 8/21/96 I see
typedef struct tagMIDIINCAPSA {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */
MMVERSION vDriverVersion; /* version of the driver */
CHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
#if (WINVER >= 0x0400)
DWORD dwSupport; /* functionality supported by driver */
#endif
} MIDIINCAPSA,*PMIDIINCAPSA,*LPMIDIINCAPSA;
Do you need to access dwSupport? If not, do you need to allocate space for
a record of this type, or do you just use pointers to a record allocated
by mmsystem?

Similar Threads:

Hi,
I'm having a problem building the example programs included with GNAT
GPL 2006 win32ada bindings. I have installed both the compiler and the
win32ada bindings (to H:\GNAT\GPL_2006), and they appear to install
correctly. But when I attempt to build any of the example programs I get
link errors. For example, using the command:
gnatmake -Pconnect.gpr
I get the following output:
gcc -c -O2 -I- -gnatA H:\GNAT\GPL_2006\examples\connect\connect.adb
gcc -c -O2 -I- -gnatA H:\GNAT\GPL_2006\examples\connect\connectpkg.adb
gnatbind -I- -x h:\gnat\gpl_2006\examples\connect\connect.ali
gnatlink h:\gnat\gpl_2006\examples\connect\connect.ali -o
h:\gnat\gpl_2006\examples\connect\connect.exe
H:\GNAT\GPL_2006\bin\..\libexec\gcc\pentium-mingw32msv\3.4.6\ld.exe:
cannot find -lwin32ada
gnatlink: cannot call H:\GNAT\GPL_2006\bin\gcc.exe
gnatmake: *** link failed.
The win32ada library that the linker seems to be looking for does not
exist in either the GPL 2006 distribution or the win32ada distribution
even though it is explicitly referenced by 'win32.ads'. If I copy this
library from my GNAT 3.15p installation the program compiles and links
correctly. Has Adacore accidentally left this file out of the win32ada
bindings, or am I doing something wrong?
Thanks.

Hi,
I'm using the following:
GNAT GPL 2007-2
Windows 2000
win32ada
When with'ing win32.glu, I get a Linker error:
i:\progra~1\gnat\2007\lib\win32ada/libwin32ada.a(win32-glu.o):win32-glu.adb:(.text+0x7b):
undefined reference to `gluErrorString@4'
objdump tells me that there is indeed a call to gluErrorString in
libwin32ada. Just how do i get it to resolve the name? -glu32 is given
in the linker options for both my project and win32ada.
Ciao,
Christian

I trying to compile some win32ada files bjut I get the following
error:
gcc -c withall.adb
win32-winnt.ads:2642:05: representation item appears too late
win32-winnt.ads:2645:05: representation item appears too late
win32-winnt.ads:2658:05: representation item appears too late
win32-winnt.ads:2659:05: representation item appears too late
gnatmake: "withall.adb" compilation error
Support libraries built.
Someone knows how to solve it? I did not get any source (yet)
available about this...
Thanks.

Hi,
I am trying to build tkimg. Do you why I cannot compile some code
unless I remove the -WX flag (treat warnings as errors)? I got the
open source from "ftp://tcl.activestate.com/pub/tcl/nightly-cvs/". Is
this the correct place to get the open source from? Are these
compiled with MS 2005, with the patch? If not, then what compiler was
used?
Thanks,
Mona.