Prev: Dhrystone
Next: Learning Ada
From: Ada novice on 25 Jul 2010 10:17 I tested under the command prompt: gcc -c imsl.adb imsl.adb:3:16: "System" is not visible imsl.adb:3:16: non-visible declaration at system.ads:40 imsl.adb:14:10: missing body for "Internal" imsl.adb:16:29: "Address" is not visible (more references follow) imsl.adb:16:29: non-visible declaration at system.ads:67 imsl.adb:17:40: "Null_Address" is not visible imsl.adb:17:40: non-visible declaration at system.ads:69 gnatmake: "imsl.adb" compilation error /YC
From: Simon Wright on 25 Jul 2010 10:26 Ada novice <posts(a)gmx.us> writes: > I tested under the command prompt: > > gcc -c imsl.adb > > imsl.adb:3:16: "System" is not visible > imsl.adb:3:16: non-visible declaration at system.ads:40 > imsl.adb:14:10: missing body for "Internal" > imsl.adb:16:29: "Address" is not visible (more references follow) > imsl.adb:16:29: non-visible declaration at system.ads:67 > imsl.adb:17:40: "Null_Address" is not visible > imsl.adb:17:40: non-visible declaration at system.ads:69 > gnatmake: "imsl.adb" compilation error Then you need to add with System; use System; to Dmitry's code. I think Internal will sort itself out when you've fixed the type-related withs as above. Personally I'd have called Internal imsl_f_eig_gen if only so I'd remember what was what! but YMMV.
From: Ada novice on 25 Jul 2010 12:18 On Jul 25, 4:26 pm, Simon Wright <si...(a)pushface.org> wrote: > > Then you need to add > with System; use System; > to Dmitry's code. > > I think Internal will sort itself out when you've fixed the type-related > withs as above. > Thanks. Now, imsl.ad(b,s) compile fine. Now to make the code work: Do I need to have a C file also? The IMSL library won't activate by itself. I have a main file in Ada as testmatrix.adb: with Imsl; use Imsl; procedure TestMatrix is Values : Complex_Array := F_Eig_Gen (((8.0, 1.0, 5.0), (4.0, 4.0, 2.0), (18.0, 5.0, 7.0))); begin null; end TestMatrix; So I compile gnatmake -c imsl.adb gnatmake -c testmatrix.adb And then work on the .ali files gnatbind -n imsl.ali testmatrix.ali I'll need a C file to do the linking. What to put in the C file? Also > Personally I'd have called Internal imsl_f_eig_gen if only so I'd > remember what was what! but YMMV. Do you mean renaming the procedure imsl.adb to Internal imsl_f_eig_gen.adb . Sorry this part is not clear to me. Thanks YC
From: Dmitry A. Kazakov on 25 Jul 2010 13:06 On Sun, 25 Jul 2010 09:18:41 -0700 (PDT), Ada novice wrote: > So I compile > > gnatmake -c imsl.adb > gnatmake -c testmatrix.adb gnatmake testmatrix.adb - > And then work on the .ali files > > gnatbind -n imsl.ali testmatrix.ali > > I'll need a C file to do the linking. What to put in the C file? C files or library files? With C files you do: gcc -c c_file.c gnatmake -c main_ada_file.adb gnatbind main_ada_file.ali gnatlink main_ada_file.ali c_file.o With library files (import or object) it is simpler gnatmake main_ada_file.adb --largs library_file.lib (If you have only a shared library then it would require a bit more work.) Better to create a gpr file for the binding and another one for the project that uses them. With gpr files you can use GPS (GNAT IDE) as well as command line: gnatmake -Pproject_file.gpr >> Personally I'd have called Internal imsl_f_eig_gen if only so I'd >> remember what was what! but YMMV. > > Do you mean renaming the procedure imsl.adb to Internal > imsl_f_eig_gen.adb . Sorry this part is not clear to me. Simon meant to name function Internal rather imsl_f_eig_gen. It is a matter of style. I agree it would be better. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: Simon Wright on 25 Jul 2010 13:24
Ada novice <posts(a)gmx.us> writes: > Thanks. Now, imsl.ad(b,s) compile fine. Now to make the code work: > > Do I need to have a C file also? The IMSL library won't activate by > itself. > I have a main file in Ada as testmatrix.adb: > > with Imsl; > use Imsl; > > procedure TestMatrix is > > Values : Complex_Array := F_Eig_Gen (((8.0, 1.0, 5.0), (4.0, 4.0, > 2.0), (18.0, 5.0, 7.0))); > > begin > null; > > end TestMatrix; > > So I compile > > gnatmake -c imsl.adb > gnatmake -c testmatrix.adb You don't need to use "-c". Try just gnatmake testmatrix.adb It'll compile testmatrix.adb and imsl.adb for you, do the bind, and try to do the link, but you'll get a linker error because it can't find imsl_f_eig_gen. Above, you wrote a C test: #include <imsl.h> int main() { int n = 3; float a[] = {8.0, -1.0, -5.0, -4.0, 4.0, -2.0, 18.0, -5.0, -7.0}; f_complex *eval; /* Compute eigenvalues of A */ eval = imsl_f_eig_gen (n, a, 0); /* Print eigenvalues */ imsl_c_write_matrix ("Eigenvalues", 1, n, eval, 0); } and when you built that you must have told GCC where to find the IMSL library: something like the "-limsl" below. gcc testprogram.c -o testprogram -limsl You can do exactly the same with gnatmake: gnatmake testmatrix.adb -largs -limsl |