The gpr file to create the library (only using the Ada parts) looks like this:
---%<---
project foo is
for source_dirs use ("src");
for object_dir use "obj";
for library_name use "foo";
for library_dir use "./lib";
for library_kind use "static";
end foo;
--->%---
Now I have a few object files built from C sources. Is it possibly to use
the gnat project file to create the static library including those object
files?
Markus
Off the top of my head, this requires that you use gprmake instead of
gnatmake. gprmake is part of GPS; if you have GPS on your system, then
maybe you have gprmake too. If you don't have it, you can still use a
Makefile to complement your project file. You can easily add an object
file to an existing static library with "ar rt libLIBRARY.a
object_file_produced_from_c.o".
--
Ludovic Brenta.
> Markus Schoepflin wrote on comp.lang.ada:
>> Using gcc 4.3.3, I'm trying to create a static library that contains both
>> object files created from Ada and C.
[...]
> Off the top of my head, this requires that you use gprmake instead of
> gnatmake. gprmake is part of GPS; if you have GPS on your system, then
> maybe you have gprmake too. If you don't have it, you can still use a
> Makefile to complement your project file. You can easily add an object
> file to an existing static library with "ar rt libLIBRARY.a
> object_file_produced_from_c.o".
Thank you for your answer.
gprmake seems pretty undocumented, but I found the documentation for
something called gprbuild which looks like it would be up to the job.
As I don't use GPS, I will probably take the Makefile route.
Markus
I suspect that gprbuild is supposed to obsolete gprmake. Sometime ago I
tried to find some info on this but couldn't arrive at anything definite. For
sure gprmake existed prior to gprbuild, and some bugs in gprmake are no
longer in gprbuild.
I'm building somewhat complex executables with a mix of Ada/C/C++ with
gprbuild with zero problems, so I expect you'll be lucky too.
You will find a GPRBuild manual at
http://www.adacore.com/category/developers-center/reference-library/documentation/feed/
if you can access it.
- Britt
The author Vincent Celier did a presentation of GPRBuild at FOSDEM
2009; the slides are online. AFAIU, GPRBuild is currently available
only to paying customers. It will be part of GNAT GPL 2009 Edition for
the general public.
--
Ludovic Brenta.
for Source_Dirs use ( "asrc", "csrc" ) ; -- for source in two dir
-- ada = asrc
-- c = csrc
for Object_Dir use "obj" ;
for Library_Dir use "./lib" ;
for Library_Name use "foo" ;
for Library_Kind use "static" ;
package Compiler is
for Default_Switches ( "Ada" ) use ( "" ) ;
for Default_Switches ( "C" ) use ( "" ) ;
end Compiler ;
end foo ;
I just checked and, on Debian, the package gnat-4.3 provides /usr/bin/
gprmake :) Enjoy!
--
Ludovic Brenta.
> The author Vincent Celier did a presentation of GPRBuild at FOSDEM
> 2009; the slides are online. AFAIU, GPRBuild is currently available
> only to paying customers. It will be part of GNAT GPL 2009 Edition for
> the general public.
gprbuild was released as part of gnat-gpl-2008, and you can get the
sources at libre.adacore.com.
gprmake was (AdaCore said June last year) a proof of concept only, and
has been removed from GCC sources. gprbuild is a separate project,
doesn't depend on the compiler version (well, not as much, anyway!)
gprbuild built and works fine on Mac OS X Leopard, intel, at any rate
for static libraries. I think my problems with dynamic libraries are
as much GCC's fault as anything, see eg http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39336
> -- This might work. It based on my design of a gpr to build libgnat
> --
> -- to build lib
> -- gnatmake -Pfoo.gpr -x
[...]
I tried your suggestion and I also added 'for languages use ("Ada", "C");',
as the gcc documentation mentions it, but the C sources are simply ignored.
Maybe it only works in AdaCore's version of gnat and not in gcc 4.3.3?
Markus
for Languages use ("Ada", "C");
and use gprbuild
Thanks for that information. I'll start packaging GCC 4.4 into Debian
soon. This will remove gprmake. After that, I will package gprbuild
for Debian. In the mean time, I suggest users of Debian stable (or
GCC 4.3 on other distributions) try gprmake.
--
Ludovic Brenta.
> I tried your suggestion and I also added 'for languages use ("Ada",
> "C");', as the gcc documentation mentions it, but the C sources are
> simply ignored.
gnatmake can compile the Ada part of a mixed-language program,
and link in the C part, but you have to use some other
method to compile the C -- usually a 'make' file.
gprbuild compile both Ada and C (and other languages).
See docs for more details.
gprmake is obsolete.
- Bob
In the past I have to enable Multi language build, by checking the
box, on the General of Preferences for multi language build to work.
A. Vo
This box is in GPS, which the OP does not use. It only instructs GPS
to invoke gprmake (in old versions) or gprbuild (in new versions)
instead of gnatmake, so we're back to square one.
--
Ludovic Brenta.
Just built GCC 4.3.3 here, no gprmake I'm afraid.
There are I believe still traces in the sources. You'd have to patch
gnattools/Makefile - variable GNATTOOLS2_FILES, I think, this was the
patch to 4.3.0:
--- trunk/gnattools/Makefile.in 2007/03/01 23:55:34 122444
+++ trunk/gnattools/Makefile.in 2007/04/30 10:14:24 124293
@@ -156,8 +156,7 @@
../../gnatxref$(exeext) \
../../gnatfind$(exeext) \
../../gnatname$(exeext) \
- ../../gnatclean$(exeext) \
- ../../gprmake$(exeext)
+ ../../gnatclean$(exeext)
# Makefile targets
# ----------------
Upgrade to Debian, then :)
--
Ludovic Brenta.