dolfin.pc does not respect library order

Bug #892793 reported by Garth Wells
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DOLFIN
Fix Released
Medium
Garth Wells

Bug Description

The library order on dolfin.pc is not consistent with the order use by cmake.

Related branches

Changed in dolfin:
milestone: none → 1.0-rc1
Revision history for this message
Anders Logg (logg) wrote :

Which order is that?

Is the problem the reversal of the order of libs when PKG_LINKFLAGS is build in dolfin/CMakeLists.txt?

# Convert libraries to -L<libdir> -l<lib> form
foreach(_lib ${DOLFIN_TARGET_LINK_LIBRARIES})
  string(REGEX REPLACE "(.?:?/[^ ]*)/lib([^ ]*)\\.(a|so|dylib|dll)" "-L\\1 -l\\2"
    _linkflags
    "${_lib}"
    )

  # Only add libraries that matches the form -L<libdir> -l<lib>
  if ("${_linkflags}" MATCHES "-L.+ -l.+")
    set(PKG_LINKFLAGS "${_linkflags} ${PKG_LINKFLAGS}")
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  endif()
endforeach()

Revision history for this message
Garth Wells (garth-wells) wrote : Re: [Bug 892793] Re: dolfin.pc does not respect library order

On 20 November 2011 21:38, Anders Logg <email address hidden> wrote:
> Which order is that?
>

The order that CMake uses when building.

> Is the problem the reversal of the order of libs when PKG_LINKFLAGS is
> build in dolfin/CMakeLists.txt?
>

Probably. We could use the trick that I added for Trilinos - reverse
the order of the set.

Garth

>
> # Convert libraries to -L<libdir> -l<lib> form
> foreach(_lib ${DOLFIN_TARGET_LINK_LIBRARIES})
>  string(REGEX REPLACE "(.?:?/[^ ]*)/lib([^ ]*)\\.(a|so|dylib|dll)" "-L\\1 -l\\2"
>    _linkflags
>    "${_lib}"
>    )
>
>  # Only add libraries that matches the form -L<libdir> -l<lib>
>  if ("${_linkflags}" MATCHES "-L.+ -l.+")
>    set(PKG_LINKFLAGS "${_linkflags} ${PKG_LINKFLAGS}")
>   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  endif()
> endforeach()
>
> --
> You received this bug notification because you are a member of DOLFIN
> Core Team, which is subscribed to DOLFIN.
> https://bugs.launchpad.net/bugs/892793
>
> Title:
>  dolfin.pc does not respect library order
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/dolfin/+bug/892793/+subscriptions
>

Revision history for this message
Anders Logg (logg) wrote :

On Sun, Nov 20, 2011 at 09:48:10PM -0000, Garth Wells wrote:
> On 20 November 2011 21:38, Anders Logg <email address hidden> wrote:
> > Which order is that?
> >
>
> The order that CMake uses when building.
>
> > Is the problem the reversal of the order of libs when PKG_LINKFLAGS is
> > build in dolfin/CMakeLists.txt?
> >
>
> Probably. We could use the trick that I added for Trilinos - reverse
> the order of the set.

Isn't it just a matter of changing the line

  set(PKG_LINKFLAGS "${_linkflags} ${PKG_LINKFLAGS}")

to

  set(PKG_LINKFLAGS "${PKG_LINKFLAGS} ${_linkflags} ${PKG_LINKFLAGS}")

?

--
Anders

> Garth
>
> >
> > # Convert libraries to -L<libdir> -l<lib> form
> > foreach(_lib ${DOLFIN_TARGET_LINK_LIBRARIES})
> >  string(REGEX REPLACE "(.?:?/[^ ]*)/lib([^ ]*)\\.(a|so|dylib|dll)" "-L\\1 -l\\2"
> >    _linkflags
> >    "${_lib}"
> >    )
> >
> >  # Only add libraries that matches the form -L<libdir> -l<lib>
> >  if ("${_linkflags}" MATCHES "-L.+ -l.+")
> >    set(PKG_LINKFLAGS "${_linkflags} ${PKG_LINKFLAGS}")
> >   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >  endif()
> > endforeach()
> >
> >
> > Title:
> >  dolfin.pc does not respect library order
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/dolfin/+bug/892793/+subscriptions
> >
>

Anders Logg (logg)
Changed in dolfin:
status: New → Confirmed
assignee: nobody → Garth Wells (garth-wells)
importance: Undecided → Medium
Anders Logg (logg)
Changed in dolfin:
milestone: 1.0-rc1 → trunk
Revision history for this message
Gerd Wachsmuth (gerd-wachsmuth) wrote :

I'm also affected by this bug. During the installation (of 1.0.0) via dorsal, the configuration of dolfin fails because he could not compile the test file for armadillo. I have to add the lines

  list(APPEND CMAKE_REQUIRED_LIBRARIES "/usr/lib64/atlas/liblapack.a" )
  list(APPEND CMAKE_REQUIRED_LIBRARIES "/usr/lib64/atlas/libcblas.a" )
  list(APPEND CMAKE_REQUIRED_LIBRARIES "/usr/lib64/atlas/libatlas.a" )
  list(APPEND ARMADILLO_LIBRARIES "/usr/lib64/atlas/liblapack.a" )
  list(APPEND ARMADILLO_LIBRARIES "/usr/lib64/atlas/libcblas.a" )
  list(APPEND ARMADILLO_LIBRARIES "/usr/lib64/atlas/libatlas.a" )

in cmake/modules/FindArmadillo.cmake:132 in order to get the compiler find those libraries.

After successful compilation, in dolfin-config.cmake, the order is "/usr/local/FEniCS/1.0.0/lib/libarmadillo.so;/usr/lib64/atlas/liblapack.a;/usr/lib64/atlas/libcblas.a;/usr/lib64/atlas/libatlas.a", whereas in dolfin.pc the order is "-latlas -lcblas -llapack -larmadillo".

The compilation of an Expression via instant works if and only if I rearrange the order in dolfin.pc to "-llapack -lcblas -latlas -larmadillo".

Johannes Ring (johannr)
Changed in dolfin:
status: Confirmed → Fix Committed
milestone: trunk → 1.0.1
Changed in dolfin:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.