comp.lang.ada
 help / color / mirror / Atom feed
* Shared Ada Library to be Used in a Non-Ada Context
@ 2005-08-08 23:35 David Sauvage
  2005-08-09  2:50 ` Jeffrey Carter
  2005-08-10  7:38 ` Ludovic Brenta
  0 siblings, 2 replies; 11+ messages in thread
From: David Sauvage @ 2005-08-08 23:35 UTC (permalink / raw)



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 <stdio.h>

//----- 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



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-08-11 23:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-08 23:35 Shared Ada Library to be Used in a Non-Ada Context David Sauvage
2005-08-09  2:50 ` Jeffrey Carter
2005-08-09 21:51   ` David Sauvage
2005-08-10  0:14     ` Georg Bauhaus
2005-08-10  7:53     ` Ludovic Brenta
2005-08-10 22:02       ` David Sauvage
2005-08-11  8:08         ` Ludovic Brenta
2005-08-11 10:41           ` Ludovic Brenta
2005-08-11 11:27             ` Georg Bauhaus
2005-08-11 23:26           ` David Sauvage
2005-08-10  7:38 ` Ludovic Brenta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox