This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to link an ADA and C library


Hello, I want to compile a project consisting on an Ada body file (and its
specification), an C body file (and its specification) and a C file with the
main entry to the program.

The C body file calls to the Ada file for different functions and with these
two files (and their specifications) I want to build a library (libCAda.a)
which can be imported and used from the C file containing the main entry.

For this building I want to use an standard compiler as gcc 3.4.4 or gcc
4.1.2 (for example), but I don't know how to get it, which flags should be
activated and the steps that can be followed.  I have tried some times and I
generate the .a but it is obviously not well-formed because I can not link
it with the main C file (I obtain an error when linking saying -> 'undefined
reference to __gnat_eh_personality').

The steps I have followed are:
1. First obtain an Ada library
gcc -c -gnatA Ada_Library.adb
gnatbind -n -o b~libada.adb *.ali
gcc -c -gnatA b~*.adb
ar rc libadafinal.a *.o

2. Obtain the C library linked with Ada library
gcc -O2 -fstrength-reduce -fno-builtin -mhard-float -ansi -o Cfile.o -c
Cfile.c
ar -x libadafinal.a
ar crus libcfinal.a *.o

3. Link the final C library with the main C file
gcc HelloWorld.c libcfinal.a -o Result.exe

Maybe am I missing a flag when binding the Ada code ... 

Can somebody help me ...

Thanks.

-- 
View this message in context: http://www.nabble.com/How-to-link-an-ADA-and-C-library-tp24715044p24715044.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]