Project

General

Profile

Bug #370

install pkg-config file for better linking

Added by Christoph Junghans almost 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

Please install a pkg-config file in $prefix/lib/pkgconfig.

We would really need that for votca, due to the fact that is complicated to find out in configure against which libs gromacs is linked.

Here is an example file:

  1. This is a comment
    prefix=/home/hp/unst # this defines a variable
    exec_prefix=${prefix} # defining another variable in terms of the first
    libdir=${exec_prefix}/lib
    includedir=${prefix}/include

Name: GObject # human-readable name
Description: Object/type system for GLib # human-readable description
Version: 1.3.1
URL: http://www.gtk.org
Requires: glib-2.0 = 1.3.1
Conflicts: foobar <= 4.5
Libs: -L${libdir} -lgobject-1.3
Libs.private: -lm
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib/include

pkg-config.patch (3.2 KB) pkg-config.patch add pkgconfig support Christoph Junghans, 12/01/2009 09:54 PM
pkgconfig.patch (7.37 KB) pkgconfig.patch add pkgconfig support Christoph Junghans, 02/26/2010 11:43 AM

Related issues

Blocked by GROMACS - Bug #470: X11 overlinkingClosed07/19/2010
Blocked by GROMACS - Bug #471: fftw overlinkingClosed07/20/2010
Blocked by GROMACS - Bug #472: gsl overlinkingClosed07/20/2010
Blocked by GROMACS - Bug #473: xml overlinkingClosed07/21/2010
Blocked by GROMACS - Bug #474: threads linkingClosed07/21/2010

Associated revisions

Revision b864fe04 (diff)
Added by Christoph Junghans over 9 years ago

Install pkgconfig files for libraries (bug #370).

Applied the patch from bugzilla. As noted in the bugzilla discussion,
the Libs.private fields currently contain several unused libraries,
which could be removed by splitting the LIBS autoconf variable into
more specific libraries.

Revision e1cf59f3 (diff)
Added by Christoph Junghans about 9 years ago

Backported pkg-config support

commit e8c878fa630b07bf75700e176b8a0ea2c35564e6
Author: Rossen Apostolov <>
Date: Tue Jul 20 12:04:17 2010 +0200

Moved the X11 automake dependency flag inside ngmx.
Only the tools in ngmx depend on X11, but all libs are linking against it.
That pulls in libX11 every time one links against gmx libs, which is really
annoying. Thanks to Christoph Junghans. Closes bug 470.

commit d065359caf79caaa80720a1a05b9efe112644eef
Author: Sander Pronk <>
Date: Thu Jul 22 12:36:03 2010 +0200

Overlinking issues with 3d party tools fixed for autotools.
Fixes a number of overlinking issues with libpthread, libfftw,
etc., and fixes CFLAGS issues for 3d party tools with
threading enabled.
Patch helpfully submitted by Christoph Junghans.

commit b864fe042787ad1aff41cb22019d6a4f84405661
Author: Christoph Junghans <>
Date: Fri Feb 26 15:32:04 2010 +0100

Install pkgconfig files for libraries (bug #370).
Applied the patch from bugzilla. As noted in the bugzilla discussion,
the Libs.private fields currently contain several unused libraries,
which could be removed by splitting the LIBS autoconf variable into
more specific libraries.

And some extra update

updated Template.mak due to split of LIBS

History

#1 Updated by Christoph Junghans almost 10 years ago

Created an attachment (id=403)
add pkgconfig support

1st Version

#2 Updated by Christoph Junghans almost 10 years ago

This patch helps to to get the right CPPFLAGS for linking.
See Victor's post on the dev mailing list!

If there is something to improve please tell.

#3 Updated by Christoph Junghans over 9 years ago

Actually it turned out to be a little more involved, due to the fact that not all libraries (mdlib,libpreprocess and gmxlib) depend on all libs in $LIBS (X11, libxml, fftw...).

I would like to have a clean solution here.

In votca-csg we need that because the .la files pull in a lot on unneeded stuff, also see:
http://blog.flameeyes.eu/2009/09/28/removing-la-files-for-dum-w-uncertain-people

and pkgconfig is obviously the best solution.

#4 Updated by Christoph Junghans over 9 years ago

This is what ldd prints out (useful for Libs.private):

ldd libmd.so
linux-gate.so.1 => (0xb78a8000)
libgmx.so.5 => /usr/lib/libgmx.so.5 (0xb75f1000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb74b3000)
libfftw3f.so.3 => /usr/lib/libfftw3f.so.3 (0xb735a000)
libm.so.6 => /lib/libm.so.6 (0xb7334000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb731a000)
libc.so.6 => /lib/libc.so.6 (0xb71d2000)
libblas.so.0 => /usr/lib/libblas.so.0 (0xb71b3000)
liblapack.so.0 => /usr/lib/liblapack.so.0 (0xb6cba000)
libdl.so.2 => /lib/libdl.so.2 (0xb6cb6000)
libz.so.1 => /lib/libz.so.1 (0xb6ca2000)
/lib/ld-linux.so.2 (0xb78a9000)
libgfortran.so.3 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgfortran.so.3 (0xb6bed000)
libatlas.so.0 => /usr/lib/libatlas.so.0 (0xb689a000)
libgslcblas.so.0 => /usr/lib/libgslcblas.so.0 (0xb685c000)
libgcc_s.so.1 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgcc_s.so.1 (0xb684e000)

ldd libgmx.so
linux-gate.so.1 => (0xb78a1000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb76a0000)
libm.so.6 => /lib/libm.so.6 (0xb767a000)
libblas.so.0 => /usr/lib/libblas.so.0 (0xb765b000)
liblapack.so.0 => /usr/lib/liblapack.so.0 (0xb7162000)
libc.so.6 => /lib/libc.so.6 (0xb7019000)
/lib/ld-linux.so.2 (0xb78a2000)
libgfortran.so.3 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgfortran.so.3 (0xb6f65000)
libatlas.so.0 => /usr/lib/libatlas.so.0 (0xb6c12000)
libgslcblas.so.0 => /usr/lib/libgslcblas.so.0 (0xb6bd4000)
libgcc_s.so.1 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgcc_s.so.1 (0xb6bc6000)

ldd libgmxana.so
linux-gate.so.1 => (0xb7888000)
libgmx.so.5 => /usr/lib/libgmx.so.5 (0xb7569000)
libmd.so.5 => /usr/lib/libmd.so.5 (0xb749a000)
libgsl.so.0 => /usr/lib/libgsl.so.0 (0xb72d8000)
libm.so.6 => /lib/libm.so.6 (0xb72b2000)
liblapack.so.0 => /usr/lib/liblapack.so.0 (0xb6db8000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb6d9f000)
libc.so.6 => /lib/libc.so.6 (0xb6c57000)
libblas.so.0 => /usr/lib/libblas.so.0 (0xb6c38000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb6afa000)
libfftw3f.so.3 => /usr/lib/libfftw3f.so.3 (0xb69a1000)
libgslcblas.so.0 => /usr/lib/libgslcblas.so.0 (0xb6962000)
/lib/ld-linux.so.2 (0xb7889000)
libatlas.so.0 => /usr/lib/libatlas.so.0 (0xb660f000)
libgfortran.so.3 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgfortran.so.3 (0xb655b000)
libgcc_s.so.1 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgcc_s.so.1 (0xb654d000)
libdl.so.2 => /lib/libdl.so.2 (0xb6549000)
libz.so.1 => /lib/libz.so.1 (0xb6534000)

ldd libgmxpreprocess.so
linux-gate.so.1 => (0xb7768000)
libmd.so.5 => /usr/lib/libmd.so.5 (0xb75ef000)
libm.so.6 => /lib/libm.so.6 (0xb75c9000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb75b0000)
libc.so.6 => /lib/libc.so.6 (0xb7468000)
libgmx.so.5 => /usr/lib/libgmx.so.5 (0xb729b000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb715d000)
libfftw3f.so.3 => /usr/lib/libfftw3f.so.3 (0xb7004000)
/lib/ld-linux.so.2 (0xb7769000)
libblas.so.0 => /usr/lib/libblas.so.0 (0xb6fe5000)
liblapack.so.0 => /usr/lib/liblapack.so.0 (0xb6aec000)
libdl.so.2 => /lib/libdl.so.2 (0xb6ae7000)
libz.so.1 => /lib/libz.so.1 (0xb6ad3000)
libgfortran.so.3 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgfortran.so.3 (0xb6a1f000)
libatlas.so.0 => /usr/lib/libatlas.so.0 (0xb66cc000)
libgslcblas.so.0 => /usr/lib/libgslcblas.so.0 (0xb668e000)
libgcc_s.so.1 => /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/libgcc_s.so.1 (0xb667f000)

libgcc, libgfortran, libdl, linux can be removed of course.

#5 Updated by Christoph Junghans over 9 years ago

Created an attachment (id=430)
add pkgconfig support

I reworked the patch and it works for us (votca.org).

However it would be nice to split LIBS in parts (GSL_LIBS,XML_LIBS,X11_LIBS,..)
to prevent overlinking of all the libs.

#6 Updated by Teemu Murtola over 9 years ago

The attached patch is now included in the git master branch. Libs.private still contains a lot of unnecessary stuff, but that can perhaps wait for later.

#7 Updated by Rossen Apostolov over 9 years ago

Can we close that bug?

#8 Updated by Christoph Junghans over 9 years ago

No, it is not fixed yet. In the current head the pc files are completely broken.

I think, there are 2 ways to solve the linking issue:
-make sure that the shared libs (.so) are always build
or
-fix the pkg-config files, to do so:
-the LIBS variable has to be split, because all gmx libs suffer from overlinking
(e.g. everything is link against X11 even if only ngmx need it) with gnu linker
one can make use of --as-need option, but this will not work for intel ibm
linker
-cmake does not have the problem of overlinking, but pc files are not build yet

As I said in the email last week, I can create a patch, but for that the decision about autotools or cmake has to made. It is just to error prone to do both.

#9 Updated by Rossen Apostolov about 9 years ago

Autotools will be removed after 4.5 and CMake will be the only build system in future releases. So there's no point in fixing that for autoconf.

#10 Updated by Christoph Junghans about 9 years ago

I will fix it for cmake then.

#11 Updated by Christoph Junghans about 9 years ago

With commit 5d67b0cf45bc3b3a28cd2c13b1d2439c6dc28803 cmake will create pc files.
For autotools it was done in commit d065359caf79caaa80720a1a05b9efe112644eef.

@Sander: There is one problem left, in cmake which variable contains "-lpthread" or equivalent?

#12 Updated by Sander Pronk about 9 years ago

(In reply to comment #11)

With commit 5d67b0cf45bc3b3a28cd2c13b1d2439c6dc28803 cmake will create pc
files.
For autotools it was done in commit d065359caf79caaa80720a1a05b9efe112644eef.

@Sander: There is one problem left, in cmake which variable contains
"-lpthread" or equivalent?

That should be PTHREADS_LIBRARY; defined in cmake/FindPThreads.cmake.

#13 Updated by Christoph Junghans about 9 years ago

Hmm strange, then I do not understand why cmake does not replace it in all the .pc.cmakein files. Do you have an idea?

#14 Updated by Sander Pronk about 9 years ago

(In reply to comment #13)

Hmm strange, then I do not understand why cmake does not replace it in all the
.pc.cmakein files. Do you have an idea?

You're right - it's defined in the cmake standard module 'FindThreads'; that defines a variable CMAKE_THREAD_LIBS_INIT. This file is inlcuded in cmake/ThreadMPI.cmake.

#15 Updated by Christoph Junghans about 9 years ago

With commit 9bd0a228144a2e577b03a4ca17bca836ec8a801f pkg-config file support for cmake is finished.

A sample Makefile using pkg-config can be found in share/template
(see Makefile.pkg), basically
CPPFLAGS=`pkg-config --cflags libmd`
LDFLAGS=`pkg-config --libs libmd`
does the trick ;-)

If there are a problems with pkg-config reopen this bugs!

Also available in: Atom PDF