An automake problem

Started by
3 comments, last by Asuralm 16 years, 1 month ago
Hi all: I want to use lapack++ which has been installed in /usr/local/lib and /usr/local/include I wrote my Automake.am as:

...
noinst_LIBRARIES = libmesh.a
libmesh_a_SOURCES = ${src}
libmesh_CPPFLAGS = -llapackpp
...


For this it can compile but when I declare a object:

LaGenMatrixFloat x(3,3);


It complains undefined reference LaGenMatrixFloat. So I tried to change the Automake.am file to

noinst_LIBRARIES = libmesh.a
libmesh_a_SOURCES = ${src}
libmesh_LDADD = lapackpp.a


But this time when I run autoreconf, it complains:
libmesh/Makefile.am:7: use `libmesh_a_LIBADD', not `libmesh_a_LDADD'
libmesh/Makefile.am:7: variable `libmesh_a_LDADD' is defined but no program or
libmesh/Makefile.am:7: library has `libmesh_a' as canonic name (possible typo)


My configure.ac file looks like:

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT([gmark], [1.0], [ming@cs.york.ac.uk])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AC_PROG_CXX
AC_PROG_CC
AC_PROG_RANLIB

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T

AC_CHECK_FUNCS([sqrt])

AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([
    Makefile
    libmesh/Makefile
])

AC_OUTPUT


Does anyone know what's the problem please? Thanks
Asura
Advertisement
Quote:Original post by Asuralm

noinst_LIBRARIES = libmesh.alibmesh_a_SOURCES = ${src}libmesh_a_LIBADD = -llapackpp

Is the way automake would have you do it. I'm not sure if libtool will take too kindly to you trying to link a DSO into a static convenience lib, but it may work.

--smw

Stephen M. Webb
Professional Free Software Developer

Sorry, I don't quite understand, could you give me some details??
Asura
Quote:Original post by Asuralm
Sorry, I don't quite understand, could you give me some details??


Hmm, I just noticed you're not using libtool.

You can't link a DSO into a static library because a static library is really just an archive of compiled object files. An object file has no clue about where it's going to be linked.

You need to either use libtool so you can specify what DSOs are required to satisfy your static library's requirements or else just link the DSO into your final executable. Maybe something linke this.
  bin_PROGRAMS = myprogram  myprogram_SOURCES = main.cpp  myprogram_LDADD =     ${path_to_libmesh}/libmesh.a     -llapackpp

If there are any further errors, post the error message, I could probably help more if I see the exact error message text.
--smw
[ edit: realized you weren't using libtool, so I had to change my answer. ]

Stephen M. Webb
Professional Free Software Developer

Thanks Bregma, that's really a good explanation.

I have tried your suggestions but it didn't seem to work.

I just found a easy way to link a static library.

No need to change the configure.ac and the source file, just add the following two lines into the Makefile.am
LIBS = -llapackppAM_CPPFLAGS = -I/usr/local/include/lapackpp


This will generate the compile command like:
g++ -g -O2 -o xxx xxx.cpp -llapackpp

And it works.

I think this maybe the easiest way to link to a static library.

Thanks again.
Asura

This topic is closed to new replies.

Advertisement