Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect order of LIBS #33

Closed
alexkay opened this issue Aug 8, 2012 · 3 comments
Closed

Incorrect order of LIBS #33

alexkay opened this issue Aug 8, 2012 · 3 comments
Milestone

Comments

@alexkay
Copy link

alexkay commented Aug 8, 2012

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.

@kaniini
Copy link
Member

kaniini commented Aug 8, 2012

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

@kaniini
Copy link
Member

kaniini commented Aug 8, 2012

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

@alexkay
Copy link
Author

alexkay commented Aug 8, 2012

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

kaniini added a commit that referenced this issue Aug 8, 2012
This bug causes occasional problems when calculating inter-module dependencies in complex
dependency graphs, such as ffmpeg when cross-compiled.

Reported-by: Alexander Kojevnikov <alexander@kojevnikov.com>
Closes: Issue #33
@kaniini kaniini closed this as completed Aug 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants