Recently I posted a note that we were working on building a static xerces library.

We have succeeded on three platforms: Windows, Sun, Linux.

On our linux boxes we are running Intel's icc8 compiler. I have not tried it with gcc, but based on what I learned along the way, I think the same solution has a very good chance of working with gcc also.

On some other platforms (Tru64, AIX, and IRIX), we have not yet found a solution. I hope to get back to that effort some time in the next few months. Where we did have problems it was generally with the inconsistent ways that various compilers deal with templates. On IRIX, we have not been able to build Xerces 2.5, so we have not tried a static build.

I will outline what we did for each of the platforms on which we were successful.

************************************************

Sun:

Sun provides a reasonably easy way to build an archive file for C++ code with an option (-xar) to the linker. This is apparently necessary, on the Sun platform, for C++ code that uses templates. The traditional ar will not work.

The only changes we made wer in the obj/Makefile.  We added:
 - symbols for the library name and the command to build the library,
 - an extra target to all: to build the library
 - a new target which does the work

% diff Makefile Makefile.orig
84,91d83
< ###################################################################
< # SPECIAL STUFF FOR TESTING STATIC BUILD #
< ###################################################################
<
< LIB_NAME = ${LIBNAME}.a
< FQ_LIB_NAME = ${XML_LIB_DIR}/${LIB_NAME}
< MAKE_STATIC = ${CXX} -D${PLATFORM} -xar ${LDFLAGS}
<
148c140
< all: ${FQ_REAL_NAME} ${FQ_LIB_NAME}
---
> all: ${FQ_REAL_NAME}
185,188d176
< ${FQ_LIB_NAME}: ${ALL_OBJECTS}
< @echo Building $(FQ_LIB_NAME)
< ${MAKE_STATIC} -o $(FQ_LIB_NAME) ${^} $(TEMPLATESOBJS) $(PLATFORM_LIBRARIES) $(EXTRA_LINK_OPTIONS) $(ALLLIBS)
<


************************************************

Linux:

The only thing we had to change was the makefile in the obj directory. That makefile builds the shared object in the normal case. I simply changed it to also build a static library the simple, old fashoned way, with ar, and it seems to have worked (yes, I was shocked too). You will notice that some, but not all, of the changes are the same as for the Sun platform above. Here are the differences:

% diff Makefile Makefile.orig
84,91d83
< ###################################################################
< #   SPECIAL STUFF FOR TESTING STATIC BUILD                        #
< ###################################################################
<
< LIB_NAME = ${LIBNAME}.a
< FQ_LIB_NAME = ${XML_LIB_DIR}/${LIB_NAME}
< MAKE_STATIC = ar -r
<
148c140
< all: ${FQ_REAL_NAME} ${FQ_LIB_NAME}
---
> all: ${FQ_REAL_NAME}
185,188d176
< ${FQ_LIB_NAME}:       $(ALL_OBJECTS)
<       @echo Building ${FQ_LIB_NAME}
<       ${MAKE_STATIC} [EMAIL PROTECTED] ${^}
<


************************************************

Windows:

A colleague did the work for Windows. I dont have all the details, but here is his synopsis of what was needed:

Changed the library type from ddl to static,

Changed the PLATFORM_EXPORT and PLATFORM_IMPORT to blank


************************************************

Those do not seem to me like major changes. It was relatively easy to do on each of those three platforms. I hope to find the magic incantation that will make it work on the other platforms we are interested in (IRIX, TRU64, and AIX). We believe that we must find a solution for AIX because the new Blue Gene Light machine will be here soon, and our understanding is that the lightweight kernel running on each node will not support shared objects.

We would deeply appreciate any hints that might help us in this. We hope that what we have done will be of use to others.


- Norm -

Norman H. Samuelson [EMAIL PROTECTED]
Lawrence Livermore National Lab 925-422-0661
P.O. Box 808, L-98
Livermore, CA 94551



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to