Skip to content

Commit

Permalink
Fix linking with internal libraries. (#339)
Browse files Browse the repository at this point in the history
When building fflas-ffpack with slibtool it fails.

ld: cannot find -lfflas
ld: cannot find -lffpack

This reveals several issues.

* Internal libraries should never link with linker flags and
  should use the libtool archive (.la) files instead.
* These should be added to LIBADD for libraries or LDADD for
  programs and never to LDFLAGS which is only for other linker
  flags.
* The _DEPENDENCIES do not need to be set manually since the
  defaults will be correct if the LIBADD/LDADD variables are
  set correctly.
* This issue is masked if fflas-ffpack is already installed
  where -lfflas and -lffpack are found installed on the system
  and not in the build directory.
* There is overlinking of dependencies where the same
  dependencies are linked repeatedly.

Making these changes allows both slibtool and GNU libtool to
build correctly, the latter is far more permissive and silently
hides this issue.
  • Loading branch information
orbea authored Sep 14, 2021
1 parent 6f4e365 commit f4d3d81
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions fflas-ffpack/interfaces/libs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pkgincludesubdir=$(pkgincludedir)/interfaces/libs

AM_CXXFLAGS = $(FFLASFFPACK_CXXFLAGS) $(GIVARO_CFLAGS) $(BLAS_CFLAGS) $(PARFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)
LDADD = $(GIVARO_LIBS) $(BLAS_LIBS) $(PARLIBS)
#AM_LDFLAGS=-static


Expand Down Expand Up @@ -55,32 +54,26 @@ libfflas_la_SOURCES= fflas_L1_inst.C \
fflas_L3_inst.C \
fflas_L3_inst_implem.inl

libfflas_la_LDFLAGS= $(LDADD) -version-info 1:0:0 \
-no-undefined
libfflas_la_LIBADD= $(GIVARO_LIBS) $(BLAS_LIBS) $(PARLIBS)
libfflas_la_LDFLAGS= -version-info 1:0:0 -no-undefined

libffpack_la_SOURCES= ffpack_inst.C \
ffpack_inst_implem.inl
libffpack_la_LDFLAGS= $(LDADD) -version-info 1:0:0 \
-no-undefined $(top_builddir)/fflas-ffpack/interfaces/libs/libfflas.la

EXTRA_libffpack_la_DEPENDENCIES= libfflas.la
libffpack_la_LIBADD= libfflas.la
libffpack_la_LDFLAGS= -version-info 1:0:0 -no-undefined

libfflas_c_la_SOURCES=fflas_lvl1.C \
fflas_lvl2.C \
fflas_lvl3.C \
fflas_sparse.C
#libfflas_c_la_CPPFLAGS=$(AM_CPPFLAGS) -DFFLAS_COMPILED -DFFPACK_COMPILED
libfflas_c_la_LDFLAGS= $(LDADD) -version-info 1:0:0 \
-no-undefined $(top_builddir)/fflas-ffpack/interfaces/libs/libfflas.la

EXTRA_libfflas_c_la_DEPENDENCIES=libfflas.la
libfflas_c_la_LIBADD= libfflas.la
libfflas_c_la_LDFLAGS= -version-info 1:0:0 -no-undefined

libffpack_c_la_SOURCES=ffpack.C
#libffpack_c_la_CPPFLAGS=$(AM_CPPFLAGS) -DFFLAS_COMPILED -DFFPACK_COMPILED
libffpack_c_la_LDFLAGS= $(LDADD) -version-info 1:0:0 \
-no-undefined -lfflas -lffpack
EXTRA_libffpack_c_la_DEPENDENCIES=libffpack.la

libffpack_c_la_LIBADD= libffpack.la
libffpack_c_la_LDFLAGS= -version-info 1:0:0 -no-undefined

EXTRA_DIST=c_libs.doxy

Expand Down

0 comments on commit f4d3d81

Please sign in to comment.