Help needed building static binaries

  • Bagpuss

    Hi There,

    Just wondering if anyone can help me.

    I'm trying to build a static binary for minidlna with the latest Samsung TV patches included. I've managed to build dynamic binaries for my ReadyNAS Duo, but I now need to build a static binary for my unRAID server.

    I've uncommented the relevant static build lines in the Makefile, and commented out the dynamic ones.

    When I try and build, the object files are created just fine, but I get failures on linking like this:

    (.text+0x11e1e): undefined reference to `dlclose'
    /usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libsqlite3.a(sqlite3.o): In function `unixDlOpen':


    /usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libavcodec.a(vaapi.o): In function `ff_vaapi_common_end_frame':
    (.text+0x5e5): undefined reference to `vaCreateBuffer'
    /usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libavcodec.a(vaapi.o): In function `ff_vaapi_common_end_frame':
    (.text+0x633): undefined reference to `vaCreateBuffer'
    collect2: ld returned 1 exit status
    make: ***  Error 1

    I'm guessing that these failures are down to the absence of relevant .a static libraries my /usr/lib. However, I'm not sure how to get the required libraries, as I can't find a way to build static archives for any of them. It also appears that you can't convert the .so libraries in to .a's.

    I'm currently trying to compile on Ubuntu 10.10, but would happily change if is would make this any easier.

    Any help would be much appreciated.



  • AzaToth

    It's not easy to build statically, as there is an implicit dependance to glibc.
    If you want to try, the full dependency are probably (libva and libgpg-error doesn't exists as static libraries under debian/ubuntu it seems though):

    -pthread -static  -ljpeg -lavformat -lavcodec -lX11 -lXext -lXfixes -ljack -lasound -ldc1394 -lraw1394 -lxvidcore -lx264 -lvpx -lvorbisenc -ltheoraenc -ltheoradec -lspeex -lschroedinger-1.0 -lorc-0.4 -lrtmp -lgnutls -lopenjpeg -lopencore-amrwb -lopencore-amrnb -lmp3lame -lgsm -lfaac -ldirac_encoder -ldirac_decoder -lstdc++ -lva -lbz2 -lgcrypt -lavcore -lavutil -lsqlite3 -lpthread -ldl -lexif -lid3tag -lz -lFLAC -lvorbis -lm -logg -lgpg-error

    you will get warnings that you are trying to build statically while depending on dynamic functions from glibc, I don't know if it's feasible to switch to any other libc.

  • Bagpuss

    Hi azatht,

    Thanks for the information. Using it, I've now managed to build a working static binary by installing the full Slackware distro that unRAID is based upon.

    I still had to go around and build static versions of ffmpeg, libid3, iibexif, libvorbis and ffmpegthumbnailer, but this was pretty straightforward.

    I understand the glibc issues, but I think I'll be okay as long as my Slackware build environment tracks the unRAID version.

    Thanks again,