[libvirt] [PATCH] compile: fix undefined reference to gnutls_x509_crt_get_dn with gcc-4.6.1

ShaoHe Feng shaohef at linux.vnet.ibm.com
Wed Oct 19 09:36:54 UTC 2011


Today, the same error encounters on my Ubuntu 11.10.
After apply this patch,  I can make Libvirt successfully.

, Xu He Jie wrote:
> 于 2011年10月18日 22:45, Eric Blake 写道:
>> On 10/18/2011 02:06 AM, Xu He Jie wrote:
>>> From: soulxu<soulxu at soulxu-ThinkPad-T410.(none)>
>>>
>>> When I compile libvirt with gcc-4.6.1 in ubuntu 11.10, got error as 
>>> below:
>>>
>>> CCLD libvirtd
>>> /usr/bin/ld: 
>>> ../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_migration.o): 
>>> undefined reference to symbol 'gnutls_x509_crt_get_dn@@GNUTLS_1_4'
>>> /usr/bin/ld: note: 'gnutls_x509_crt_get_dn@@GNUTLS_1_4' is defined 
>>> in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so so try adding it to 
>>> the linker command line
>>> /usr/lib/x86_64-linux-gnu/libgnutls.so: could not read symbols: 
>>> Invalid operation
>>> collect2: ld returned 1 exit status
>>> make[3]: *** [libvirtd] Error 1
>>>
>>>
>>> It can compile with gcc-4.5.2 in ubuntu 11.04, but it can not 
>>> compile with gcc-4.6.1 in ubuntu 11.10.
>>>
>>> I didn't find reason. Does Anyone know the reason or the different 
>>> between gcc-4.5.2 and gcc-4.6.1?
>>
>> More likely, the difference is not in gcc, but in ld policy - Ubuntu 
>> recently changed policy to no longer allow implicit link dependencies 
>> by default (that is, if A links against B, and B links against C, 
>> older distros allowed A to use symbols from C without explicitly 
>> linking against C, while newer distros require the explicit link).
>>
>>>
>>> I still provide a patch for this. Just make it is working now.
>>>
>>> Signed-off-by: soulxu<soulxu at soulxu-ThinkPad-T410.(none)>
> Just found I forgot configuring git. The Signed-off-by should be:
> Signed-off-by: Xu He Jie <xuhj at linux.vnet.ibm.com>
>>> ---
>>> src/Makefile.am | 6 +++++-
>>> 1 files changed, 5 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/src/Makefile.am b/src/Makefile.am
>>> index 87d91ed..104efc6 100644
>>> --- a/src/Makefile.am
>>> +++ b/src/Makefile.am
>>> @@ -776,10 +776,14 @@ noinst_LTLIBRARIES += libvirt_driver_qemu.la
>>> #libvirt_la_BUILT_LIBADD += libvirt_driver_qemu.la
>>> endif
>>> libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS) \
>>> + $(GNUTLS_CFLAGS) \
>>> + $(LIBXML_CFLAGS) \
>>
>> I understand the addition of GNUTLS_CFLAGS, but why LIBXML_CFLAGS? 
>> Did you get a second link error?
> Yes, I get a second link error. When I just add GNUTLS_LIBS to there, 
> I get another error, as below:
>
> /usr/bin/ld: 
> ../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_domain.o): 
> undefined reference to symbol 'xmlXPathRegisterNs@@LIBXML2_2.4.30'
> /usr/bin/ld: note: 'xmlXPathRegisterNs@@LIBXML2_2.4.30' is defined in 
> DSO /usr/lib/libxml2.so so try adding it to the linker command line
> /usr/lib/libxml2.so: could not read symbols: Invalid operation
> collect2: ld returned 1 exit status
> make[3]: *** [libvirtd] Error 1
>
> So I add LIBXML_CFLAGS and LIBXML_LIBS to there too.
>>
>>> -I at top_srcdir@/src/conf $(AM_CFLAGS)
>>> libvirt_driver_qemu_la_LDFLAGS = $(AM_LDFLAGS)
>>> libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS) \
>>> - $(CAPNG_LIBS)
>>> + $(CAPNG_LIBS) \
>>> + $(GNUTLS_LIBS) \
>>> + $(LIBXML_LIBS)
>>
>> Likewise.
>>
>> Your approach to a fix is correct, but I need to know whether to use 
>> the patch as-is or whether we just need one library rather than two.
>>
>
> -- 
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list




More information about the libvir-list mailing list