Incorrect order of LIBS #33

Closed
opened 2012-08-08 05:35:56 +00:00 by alexkay · 3 comments
alexkay commented 2012-08-08 05:35:56 +00:00 (Migrated from github.com)

I'm using MXE to cross-compile (and statically link to) FFmpeg and other libraries. On FreeBSD (which recently switched to pkgconf) the order of LIBS flags is incorrect which leads to numerous undefined reference to ... errors during linking. On Debian Sid (which uses pkg-config) the order is correct and linking works.

Relevant configure.ac snippet:

pkg_modules="libavformat >= 52.111 libavcodec >= 52.123 libavutil"
PKG_CHECK_MODULES(SPEK, [$pkg_modules])
AC_SUBST(SPEK_CFLAGS)
AC_SUBST(SPEK_LIBS)

LIBS with pkgconf, snippet from config.log:

pkg_cv_SPEK_LIBS='-L/home/alex/Projects/mxe/usr/i686-pc-mingw32/lib -lavutil -lm -lavcodec -lavicap32 -lws2_32 -lmingw32 -lSDLmain -lSDL -lwinmm -mwindows -liconv -luser32 -lgdi32 -ldxguid -lxvidcore -lx264 -lvpx -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -lspeex -lopencore-amrwb -lopencore-amrnb -lmp3lame -lavifil32 -lbz2 -lz -lpsapi -lavformat '

LIBS with pkg-config, snippet from config.log:

pkg_cv_SPEK_LIBS='-mwindows -L/home/alex/Projects/mxe/usr/i686-pc-mingw32/lib -lavformat -lavcodec -lavicap32 -lws2_32 -lmingw32 -lSDLmain -lSDL -liconv -luser32 -lgdi32 -lwinmm -ldxguid -lxvidcore -lx264 -lvpx -lvorbisenc -lvorbis -ltheoraenc -ltheoradec -logg -lspeex -lopencore-amrwb -lopencore-amrnb -lmp3lame -lavifil32 -lbz2 -lz -lpsapi -lavutil -lm  '

The correct dependency order is avformat → avcodec → avutil, with pkgconf it's reversed.

Please let me know if you need additional info.

I'm using [MXE](http://mxe.cc/) to cross-compile (and statically link to) [FFmpeg](http://ffmpeg.org/) and other libraries. On FreeBSD (which recently switched to `pkgconf`) the order of `LIBS` flags is incorrect which leads to numerous `undefined reference to ...` errors during linking. On Debian Sid (which uses `pkg-config`) the order is correct and linking works. Relevant `configure.ac` snippet: ``` pkg_modules="libavformat >= 52.111 libavcodec >= 52.123 libavutil" PKG_CHECK_MODULES(SPEK, [$pkg_modules]) AC_SUBST(SPEK_CFLAGS) AC_SUBST(SPEK_LIBS) ``` `LIBS` with `pkgconf`, snippet from `config.log`: ``` pkg_cv_SPEK_LIBS='-L/home/alex/Projects/mxe/usr/i686-pc-mingw32/lib -lavutil -lm -lavcodec -lavicap32 -lws2_32 -lmingw32 -lSDLmain -lSDL -lwinmm -mwindows -liconv -luser32 -lgdi32 -ldxguid -lxvidcore -lx264 -lvpx -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -lspeex -lopencore-amrwb -lopencore-amrnb -lmp3lame -lavifil32 -lbz2 -lz -lpsapi -lavformat ' ``` `LIBS` with `pkg-config`, snippet from `config.log`: ``` pkg_cv_SPEK_LIBS='-mwindows -L/home/alex/Projects/mxe/usr/i686-pc-mingw32/lib -lavformat -lavcodec -lavicap32 -lws2_32 -lmingw32 -lSDLmain -lSDL -liconv -luser32 -lgdi32 -lwinmm -ldxguid -lxvidcore -lx264 -lvpx -lvorbisenc -lvorbis -ltheoraenc -ltheoradec -logg -lspeex -lopencore-amrwb -lopencore-amrnb -lmp3lame -lavifil32 -lbz2 -lz -lpsapi -lavutil -lm ' ``` The correct dependency order is `avformat → avcodec → avutil`, with `pkgconf` it's reversed. Please let me know if you need additional info.

Probably caused by the pkg_queue_compile stuff. I'll get it done for pkgconf 0.8.6.

Probably caused by the pkg_queue_compile stuff. I'll get it done for pkgconf 0.8.6.

I am not able to reproduce this locally, can you provide --digraph output for the problem "libavformat >= 52.111 libavcodec >= 52.123 libavutil"?

I am not able to reproduce this locally, can you provide --digraph output for the problem "libavformat >= 52.111 libavcodec >= 52.123 libavutil"?
alexkay commented 2012-08-08 14:25:46 +00:00 (Migrated from github.com)

I test case to reproduce the issue (I ran this on Debian Sid):

# From an empty dir:
% git clone git://github.com/pkgconf/pkgconf.git
% cd pkgconf
% ./autogen.sh
% ./configure
% make
% cd ..
% git clone git://git.videolan.org/ffmpeg.git
% cd ffmpeg
% git checkout n0.10.4
% ./configure --prefix=/tmp/ffmpeg
% make -j8
% make install
% PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ../pkgconf/pkgconf --libs "libavformat >= 52.111 libavcodec >= 52.123 libavutil"
-L/tmp/ffmpeg/lib -lavutil -lm -lavcodec -ldl -pthread -lz -lavformat
% PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ../pkgconf/pkgconf --digraph "libavformat >= 52.111 libavcodec >= 52.123 libavutil"
graph deptree {
edge [color=blue len=7.5 fontname=Sans fontsize=8]
node [fontname=Sans fontsize=8]
"libavutil" [fontname=Sans fontsize=8]
"libavcodec" [fontname=Sans fontsize=8]
"libavutil" -- "libavcodec" [fontname=Sans fontsize=8]
"libavformat" [fontname=Sans fontsize=8]
"libavcodec" -- "libavformat" [fontname=Sans fontsize=8]
"libavutil" [fontname=Sans fontsize=8]
"libavcodec" [fontname=Sans fontsize=8]
"libavutil" -- "libavcodec" [fontname=Sans fontsize=8]
"libavutil" [fontname=Sans fontsize=8]
"world" [fontname=Sans fontsize=8]
"libavformat" -- "world" [fontname=Sans fontsize=8]
"libavcodec" -- "world" [fontname=Sans fontsize=8]
"libavutil" -- "world" [fontname=Sans fontsize=8]
}

Stock pkg-config returns correct LIBS:

% PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig /usr/bin/pkg-config --libs "libavformat >= 52.111 libavcodec >= 52.123 libavutil" 
-pthread -L/tmp/ffmpeg/lib -lavformat -lavcodec -ldl -lz -lavutil -lm
I test case to reproduce the issue (I ran this on Debian Sid): ``` # From an empty dir: % git clone git://github.com/pkgconf/pkgconf.git % cd pkgconf % ./autogen.sh % ./configure % make % cd .. % git clone git://git.videolan.org/ffmpeg.git % cd ffmpeg % git checkout n0.10.4 % ./configure --prefix=/tmp/ffmpeg % make -j8 % make install % PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ../pkgconf/pkgconf --libs "libavformat >= 52.111 libavcodec >= 52.123 libavutil" -L/tmp/ffmpeg/lib -lavutil -lm -lavcodec -ldl -pthread -lz -lavformat % PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ../pkgconf/pkgconf --digraph "libavformat >= 52.111 libavcodec >= 52.123 libavutil" graph deptree { edge [color=blue len=7.5 fontname=Sans fontsize=8] node [fontname=Sans fontsize=8] "libavutil" [fontname=Sans fontsize=8] "libavcodec" [fontname=Sans fontsize=8] "libavutil" -- "libavcodec" [fontname=Sans fontsize=8] "libavformat" [fontname=Sans fontsize=8] "libavcodec" -- "libavformat" [fontname=Sans fontsize=8] "libavutil" [fontname=Sans fontsize=8] "libavcodec" [fontname=Sans fontsize=8] "libavutil" -- "libavcodec" [fontname=Sans fontsize=8] "libavutil" [fontname=Sans fontsize=8] "world" [fontname=Sans fontsize=8] "libavformat" -- "world" [fontname=Sans fontsize=8] "libavcodec" -- "world" [fontname=Sans fontsize=8] "libavutil" -- "world" [fontname=Sans fontsize=8] } ``` Stock `pkg-config` returns correct LIBS: ``` % PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig /usr/bin/pkg-config --libs "libavformat >= 52.111 libavcodec >= 52.123 libavutil" -pthread -L/tmp/ffmpeg/lib -lavformat -lavcodec -ldl -lz -lavutil -lm ```
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ariadne/pkgconf#33
There is no content yet.