Opened 7 years ago

Closed 7 years ago

#751 closed defect (fixed)

Add `-lrt` to pkg-config if necessary.

Reported by: mgautier Owned by: Olly Betts
Priority: normal Milestone: 1.4.5
Component: Build system Version: git master
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description

If xapian uses rt library, the -lrt flag must be present in the pkg-config settings.

This patch add it if necessary.

Attachments (1)

pkgconfig_librt.patch (1.7 KB ) - added by mgautier 7 years ago.

Download all attachments as: .zip

Change History (6)

by mgautier, 7 years ago

Attachment: pkgconfig_librt.patch added

comment:1 by Olly Betts, 7 years ago

Component: OtherBuild system
Type: enhancementdefect

I don't know much about pkg-config, but this doesn't sound right to me - the application linked against xapian doesn't need any symbols from librt, only the xapian library itself does.

I think the correct fix is to add:

Libs.private: @XAPIAN_LIBS@

What platform are you seeing this on? Presumably one without DT_NEEDED or equivalent.

comment:2 by Olly Betts, 7 years ago

Could you please respond to the question in my previous comment, and let me know if the suggested fix works for you?

It'd be good to address this in the imminent 1.4.5 release.

comment:3 by mgautier, 7 years ago

Sorry, I forget you and this issue ...

I've just test what you've suggested and it seems to work perfectly. I had to change a bit my build system, but it is not your problem :)

For you information, we are building a library using xapian and different platform (native and cross-compilation (win32, armhf, android, ...)) with native and dynamic linking. The host platform is linux (fedora and ubuntu). I didn't know about DT_NEEDED but it seems that linux has it. The problem (undefined symbol) appears when doing static linking.

Anyway, adding Libs.private: @XAPIAN_LIBS@ fixes my problem and it is a far better solution than my patch. It would be nice to have it in the next xapian release.

Thanks.

comment:4 by Olly Betts, 7 years ago

Milestone: 1.4.5
Status: newassigned

Linux does have DT_NEEDED for shared libraries - it's essentially a list of dependencies embedded in a shared library so that when the system dynamically loads libxapian.so it knows it has to dynamically load all these other libraries:

$ readelf -a /usr/lib/x86_64-linux-gnu/libxapian.so|grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libuuid.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]

I don't think there's an equivalent way for a .a to encode dependencies, so it has to be handled at a higher level.

Thanks for the confirmation, will apply the Libs.private change for 1.4.5.

comment:5 by Olly Betts, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.