[PD-dev] how to load shared code for libraries

Hans-Christoph Steiner hans at at.or.at
Sat Oct 29 16:35:19 CEST 2011


On Oct 29, 2011, at 10:26 AM, IOhannes m zmölnig wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 10/19/2011 01:29 AM, Hans-Christoph Steiner wrote:
>> I committed the change to tkwidgets and the template/Makefile.
>> 
> 
> i tried to use the new template/Makefile for this feature and noticed a
> few issues:
> - - object sources are called SOURCES, whereas shared sources are called
> SHARED_SOURCE (singular); same goes for SHARED_HEADER
> for consistency sake, i propose to use plural throughout.
> 
> - - the output name of the shared lib cannot be simply overridden (it
> derives from the value of SHARED_SOURCE)
> 
> - - using multiple C-files for the shared code, doesn't really work: it
> tries to create a shared library from each C-file (so if you
> SHARED_SOURCE="foo.c bar.c", you will end up with both foo.so and
> bar.so, and your objecctclass will link against all those.
> it seems like you only used a "single C-file" library, but i guess a
> number of libs will also want to use multiple C-files for building a
> single library, which should then be linked to all objectclasses.
> (this get's you all the features from creating a shared lib from each
> SHARED_SOURCE file, and additionally allows the shared code to share
> code with itself)
> 
> therefore i propose a few small amendments to template/Makefile:
> - - rename SHARED_SOURCE to SHARED_SOURCES
> - - rename SHARED_HEADER to SHARED_HEADERS
> - - build all shared sources into a single library
> - - as default name, use "lib$(LIBRARY).so" for this library
> - - allow the user to easily override this name, if they want to

These things are really all by design.  This makefile template is not trying to be all things to all people, but instead provide the easiest solution for 98% of the cases.  By not handling that 2%, it can be make much simpler for everyone else.  

- SHARED_SOURCE is lib$(LIBRARY_NAME).c, if you need multiple files, you need to modify things

- the shared lib name is deliberately standardized, therefore its not settable

This means that a dev can easily tell whether a lib contains a shared lib, and where its source code is.  Its self-documenting once you know it.  You just look at the file system, and you know where things are.

.hc

----------------------------------------------------------------------------

The arc of history bends towards justice.     - Dr. Martin Luther King, Jr.





More information about the Pd-dev mailing list