ccan dependencies seems to break external projects

Matthieu Patou mat at
Sun Feb 12 13:37:50 MST 2012

On 02/12/2012 10:08 AM, Jelmer Vernooij wrote:
> On 02/12/2012 06:57 PM, Matthieu Patou wrote:
>> On 02/12/2012 04:52 AM, Jelmer Vernooij wrote:
>>> On Sat, Feb 11, 2012 at 02:49:20PM -0800, Matthieu Patou wrote:
>>>> I'm trying to compile openchange as described here : 
>>>> I'm using the latest git tree instead of alpha17, after a couple of
>>>> tweak in the script that setup the prerequisits I have a samba4 with
>>>> using system talloc/tdb/tevent and ldb.
>>>> Then I try to build openchange and got:
>>>> /usr/local/src/openchange$ make
>>>> Linking sample application bin/libmapixx-test
>>>> g++ -I.  -O3 -Wall -g3 -fstrict-aliasing -Wp,-D_FORTIFY_SOURCE=2
>>>> -Wl,-rpath,/usr/local/samba/lib -I/usr/local/samba/include
>>>>     -I/usr/local/samba/include   -I/usr/local/samba/include
>>>> -I/usr/local/samba/include     -o bin/libmapixx-test
>>>> libmapi++/tests/test.cpp
>>>> .11 -Wl,-rpath,/usr/local/samba/lib -L/usr/local/samba/lib -ldcerpc
>>>> -ldcerpc-binding -lndr -lsamba-hostconfig -lsamba-util -ltevent
>>>> -ltalloc   -Wl,-rpath,/usr/local/samb
>>>> a/lib -L/usr/local/samba/lib -lldb -ltalloc
>>>> -Wl,-rpath,/usr/local/samba/lib -L/usr/local/samba/lib -ltalloc
>>>> -lpthread
>>>> /usr/local/samba/lib/ undefined reference to
>>>> `hash_any at SAMBA_4.0.0ALPHA18_GIT_0B3A262'
>>>> The hash_any symbol comes from the ccan library and is included in
>>>> via source3/util/
>>>> I suspect there is a symbols collision when you build samba 4 with
>>>> system libs as ldb has its own version of ccan but obviously with a
>>>> different version although it seems that ldb didn't directly need
>>>> ccan (no ccan in the output of ldd, the following command
>>>> ls /usr/local/systemsamba/lib/ldb/* output this:
>>>> /usr/local/systemsamba/lib/ldb/
>>>> /usr/local/systemsamba/lib/ldb/
>>>> There is no way to have a system ccan and it seems that there is no
>>>> easy way to use the one built for ldb as the "system" ccan.
>>>> I don't know what can be done, the cheapest is to have a
>>>> source3/util not to depend on ccan if --disable-tdb2 was specified
>>>> on the command line.
>>> Does ccan really have to be a separate library? Its goal seems to be
>>> the same as the 'samba-util' library.
>>> If I understand correctly ccan isn't really meant as a shared library
>>> with utility functions but rather as a collection of C files that you
>>> can pick a few useful ones from.
>>> Would it perhaps be possible to just include the relevant files from
>>> ccan in libsamba-util?
>> I'm not sure how this will fix the problem.
>> Let say that we have ccan in samba-util, instead of depending on 
>> ccan, ldb will depend on samba-util.
>> It means if I understand well that we will have a 
>> with a version 1.4.1 (the version of ldb) but as it seems that we 
>> have no way to use a system samba-util library when building samba4 
>> will have also a version of this library SAMBA_4.0.0ALPHA...
> tdb can include whatever it needs from ccan in the same way as 
> samba-util does (AFAIK it only uses a single macro from ccan at the 
> moment).
> ccan doesn't have a well-defined ABI. The problem with the way you're 
> building ldb and Samba is that you end up with two versions of the 
> ccan library - one which does have hash_any and one which doesn't. The 
> linker only tries to load one and not the other, because it remembers 
> it has already loaded ccan.
It seems to me that both have the symbols:
# the one from ldb
mat at mpatou-t420:/usr/local/src/samba$ nm 
/usr/local/systemsamba/lib/ldb/ | grep hash_any
000000000000258b T hash_any
# the one built by samba
mat at mpatou-t420:/usr/local/src/samba$ nm bin/shared/private/ 
| grep hash_any
00000000000025eb T hash_any

As far as I understand I see two different lib version:
mat at mpatou-t420:/usr/local/src/samba$ nm bin/shared/private/ 
| grep " A "
0000000000000000 A SAMBA_4.0.0ALPHA18_DEVELOPERBUILD
00000000002060b0 A __bss_start
00000000002060b0 A _edata
00000000002060c0 A _end

mat at mpatou-t420:/usr/local/src/samba$ nm 
/usr/local/systemsamba/lib/ldb/ | grep " A "
0000000000000000 A LDB_1.1.4
00000000002060b0 A __bss_start
00000000002060b0 A _edata
00000000002060c0 A _end

I'm not quite sure of what is not working with the linker but I don't 
think it's because the first loaded lib hasn't the hash_any symbol.

I'm wondering if it wouldn't be more easy to duplicate the macro rather 
to make quite complicated things for just 1 symbol in ldb.


Matthieu Patou
Samba Team

More information about the samba-technical mailing list