From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9a720a14a5d106b,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!news.glorb.com!news.germany.com!newsfeed1.funet.fi!newsfeeds.funet.fi!newsfeed1.swip.net!swipnet!nntpserver.swip.net!not-for-mail From: David Sauvage User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Shared Ada Library to be Used in a Non-Ada Context Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: NNTP-Posting-Host: 83.177.248.28 X-Complaints-To: news-abuse@swip.net X-Trace: nntpserver.swip.net 1123544008 83.177.248.28 (Tue, 09 Aug 2005 01:33:28 MET DST) NNTP-Posting-Date: Tue, 09 Aug 2005 01:33:28 MET DST Organization: A Customer of Tele2 X-Sender: -@d83-177-248-28.cust.tele2.fr Date: Tue, 09 Aug 2005 01:35:38 +0200 Xref: g2news1.google.com comp.lang.ada:4041 Date: 2005-08-09T01:35:38+02:00 List-Id: Hi, I'm trying to make a simple illustration (that work) of building an Ada shared library to be Used in a Non-Ada Context (errors & sources below) I think i got problems during my build process or i'm wrong somewhere else ;-) Any tips ? thanks ;-) David CASE 1 : using gnatbind -Lservices libservices ------- exemple$ make gnatmake -fPIC -Wall -c libservices.adb gcc-3.4 -c -fPIC -Wall libservices.adb gnatbind -Lservices libservices gcc -g -fPIC -Wall -c b~libservices.adb gcc: installation problem, cannot exec `gnat1': Aucun fichier ou r�pertoire de ce type make: *** [libservices.so] Erreur 1 CASE 2 : using gnatbind -C -Lservices libservices ------- exemple$ make gnatmake -fPIC -Wall -c libservices.adb gcc-3.4 -c -fPIC -Wall libservices.adb gnatbind -C -Lservices libservices gcc -g -fPIC -Wall -c b_libservices.c gcc -g -fPIC -Wall -shared -W1,-soname,libservices.so -o libservices.so b_libservices.o gcc -L. -lservices -o main /usr/lib/gcc-lib/i486-linux/3.3.5/../../../crt1.o(.text+0x18): In function `_start': ../sysdeps/i386/elf/start.S:98: undefined reference to `main' ./libservices.so: undefined reference to `system__secondary_stack___elabb' ./libservices.so: undefined reference to `__gnat_handler_installed' ./libservices.so: undefined reference to `system__soft_links___elabb' ./libservices.so: undefined reference to `system__secondary_stack_E' ./libservices.so: undefined reference to `ada__exceptions___elabs' ./libservices.so: undefined reference to `__gnat_set_globals' ./libservices.so: undefined reference to `system__exception_table_E' ./libservices.so: undefined reference to `system__exceptions___elabs' ./libservices.so: undefined reference to `libservices_E' ./libservices.so: undefined reference to `__gnat_install_handler' ./libservices.so: undefined reference to `system__soft_links_E' ./libservices.so: undefined reference to `ada__exceptions___elabb' ./libservices.so: undefined reference to `system__exceptions_E' ./libservices.so: undefined reference to `system__standard_library__adafinal' ./libservices.so: undefined reference to `system__exception_table___elabb' ./libservices.so: undefined reference to `ada__exceptions_E' collect2: ld a retourn� 1 code d'�tat Files listings : main.c libservices.adb libservices.ads Makefile >>>>>>>>>>>>>>>>>> main.c <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include //----- shared library interfaces /* the library elaboration procedure */ extern void servicesinit (void); /* the library finalization procedure */ extern void servicesfinal (void); /* the library service method */ extern void service_1 (void); //----- application main method int main(int argc, char **argv) { servicesinit(); service_1 (); servicesfinal (); return 1; } >>>>>>>>>>>>>>>>>> libservices.adb <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< package body Libservices is -- ------------------- procedure Service_1 is begin null; end Service_1; end Libservices; >>>>>>>>>>>>>>>>>> libservices.ads <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< package Libservices is -- ------------------- procedure Service_1; pragma Export(C, Service_1, "service_1"); end Libservices; >>>>>>>>>>>>>>>>>> Makefile <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OBJS = libservices.so main all : $(OBJS) libservices.so : libservices.adb libservices.ads gnatmake -fPIC -Wall -c libservices.adb # CASE 1 : gnatbind -Lservices libservices gcc -g -fPIC -Wall -c b~libservices.adb gcc -g -fPIC -Wall -shared -W1,-soname,libservices.so -o libservices.so b~libservices.o # CASE 2 : # gnatbind -C -Lservices libservices # gcc -g -fPIC -Wall -c b_libservices.c # gcc -g -fPIC -Wall -shared -W1,-soname,libservices.so -o libservices.so b_libservices.o main : libservices.so main.c gcc -L. -lservices -o main clean : rm -f *.o *.ali b~* *~ b_libservices.c libservices.so