static library linking

Added by John Ryland over 3 years ago

Hi,

I'm using JamPlus for cross-platform building with success and like it so far. Thanks for the great tool, it seems to meet my needs well.

However I am running in to a few issues and I'm trying to work around or fix them. Please help me find the correct ways I should be solving these problems if I am doing it wrong or comments.

The main problem is with linking static libraries together in to a static library (optionally with more object files). The particular problem is that our product is released as a static library but internally we develop the product as modules which for dependencies to the module that is compiled as the library we give to the customer. We don't want the customer to have the internal libs separately, just the public API in a header file and the associated single static lib. But this seems difficult. It seems this is not so easy with the gnu ar command although I found the 'T' option which gets close to doing what I want together with setting the undocumented C.LibFlags for the project to the list of static libs to link in. However the C.Archive rule seems to be incorrect. Suggested patch below:

--- /jamplus/bin/modules/c-compilers/c-gcc.jam 2014-05-15 03:46:43.000000000 1000
+++ /jamplus/bin/modules/c-compilers/c-gcc.jam 2014-05-15 03:46:43.000000000 1000
@ -64,7 +64,7 @

actions updated together piecemeal C.Archive
{
- "$(C.AR)" $(LIBFLAGS) $(<:C) $(>:C)
+ "$(C.AR)" $(<:C) $(LIBFLAGS) $(>:C)
}
actions C.Link
@ -85,7 +85,7 @ {
actions C.Archive {
- "$(C.AR)" $(LIBFLAGS) $(<:C) $(>:C)
+ "$(C.AR)" $(<:C) $(LIBFLAGS) $(>:C)
}
}

The C.AR command is already defined to be "ar ru" where "ru" are options that means ar expects the first argument after this to be the output file name. So I believe the correct thing would be for $(<:C) to appear before $(LIBFLAGS), although perhaps the intended use of C.LibFlags might be to add additional options to the "ru" options but that would be assuming no space would be inserted between the expansion of "$(C.AR)" and $(LIBFLAGS) which as it stands I don't think is the case.

I'm still not sure about my work around for linking static libs together. Any help or comments would be appreciated on ways to do this besides this patch and setting C.LibFlags with the libraries and changing the C.AR command to be "ar ruT".

Another minor issue I'm working around okay for now is I found linux64 support seemed to be missing. I added in bin/modules/c-compilers/ appropriate files named linux64*.jam which are based on the linux32 files but replacing anywhere that 64 appears with 32 instead. I didn't find these files in any repos I could find but if I am just getting jamplus from the wrong place please point me to the most up to date place.

Thanks
John