problems when cross-compiling libaacs for windows in ubuntu

This forum is about all development around libVLC.
nalor
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Jul 2015 20:57

problems when cross-compiling libaacs for windows in ubuntu

Postby nalor » 09 Jul 2015 21:18

Hello!

I spent hours on the internet to find an easy manual that tell me how I can compile the libaacs source myself for windows operating system but couldn't find anything suitable.

Finally I started to follow the general vlc compile instructions here: https://wiki.videolan.org/Win32Compile/
  • installed ubuntu 14.4lts 32 bit in virtualbox
    installed ssh server
    started to connect with putty because it's more convenient ;)
    installed the mingw-w64 toolchain as requested on the wiki page
    saved the script to 'enforce static compilation' in a sh-file and executed it
    installed all 'development tools' listed on the wiki page
    decided that >i686-w64-mingw32< is the correct host-triplet in my case
    copied the source code of libaacs-0.8.1 with winscp in a subfolder on my virtual ubuntu
    skipped the part about 'prepare 3rd party libraries' because there's no folder 'contrib' in the source directory of libaacs-0.8.1
    executed the steps listed unter 'Configuring the build'
    >> bootstrap
    >> configure (but skipped the PKG_CONFIG_LIBDIR section because I still don't have a 'contrib' folder)
    (installed bison and libgcrypt because configure failed without them)
    and finally I tried to execute make but it fails immediatly
The result of the 'make' execution is:

Code: Select all

root@test-VirtualBox:/home/test/libaacs-0.8.1# make make all-am make[1]: Verzeichnis »/home/test/libaacs-0.8.1« wird betreten CC src/libaacs/aacs.lo src/libaacs/aacs.c:44:20: fatal error: gcrypt.h: No such file or directory #include <gcrypt.h> ^ compilation terminated. make[1]: *** [src/libaacs/aacs.lo] Fehler 1 make[1]: Verzeichnis »/home/test/libaacs-0.8.1« wird verlassen make: *** [all] Fehler 2
I guess the problem might be related to a warning I get during the configure-step:

Code: Select all

root@test-VirtualBox:/home/test/libaacs-0.8.1# ./configure --host=i686-w64-mingw32 checking build system type... i686-pc-linux-gnu checking host system type... i686-w64-mingw32 checking target system type... i686-w64-mingw32 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for i686-w64-mingw32-strip... i686-w64-mingw32-strip checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether UID '0' is supported by ustar format... yes checking whether GID '0' is supported by ustar format... yes checking how to create a ustar tar archive... gnutar checking whether to enable maintainer-specific portions of Makefiles... no checking whether make supports nested variables... (cached) yes checking for i686-w64-mingw32-gcc... i686-w64-mingw32-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.exe checking for suffix of executables... .exe checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether i686-w64-mingw32-gcc accepts -g... yes checking for i686-w64-mingw32-gcc option to accept ISO C89... none needed checking whether i686-w64-mingw32-gcc understands -c and -o together... yes checking for style of include used by make... GNU checking dependency style of i686-w64-mingw32-gcc... gcc3 checking how to print strings... printf checking for a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by i686-w64-mingw32-gcc... /usr/bin/i686-w64-mingw32-ld checking if the linker (/usr/bin/i686-w64-mingw32-ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/i686-w64-mingw32-nm -B checking the name lister (/usr/bin/i686-w64-mingw32-nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert i686-pc-linux-gnu file names to i686-w64-mingw32 format... func_convert_file_nix_to_w32 checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/i686-w64-mingw32-ld option to reload object files... -r checking for i686-w64-mingw32-objdump... i686-w64-mingw32-objdump checking how to recognize dependent libraries... (cached) pass_all checking for i686-w64-mingw32-dlltool... i686-w64-mingw32-dlltool checking how to associate runtime and link libraries... func_cygming_dll_for_implib checking for i686-w64-mingw32-ar... i686-w64-mingw32-ar checking for archiver @FILE support... @ checking for i686-w64-mingw32-strip... (cached) i686-w64-mingw32-strip checking for i686-w64-mingw32-ranlib... i686-w64-mingw32-ranlib checking command to parse /usr/bin/i686-w64-mingw32-nm -B output from i686-w64-mingw32-gcc object... ok checking for sysroot... no checking for i686-w64-mingw32-mt... no checking for mt... mt checking if mt is a manifest tool... no checking how to run the C preprocessor... i686-w64-mingw32-gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... no checking for objdir... .libs checking if i686-w64-mingw32-gcc supports -fno-rtti -fno-exceptions... no checking for i686-w64-mingw32-gcc option to produce PIC... -DDLL_EXPORT -DPIC checking if i686-w64-mingw32-gcc PIC flag -DDLL_EXPORT -DPIC works... yes checking if i686-w64-mingw32-gcc static flag -static works... yes checking if i686-w64-mingw32-gcc supports -c -o file.o... yes checking if i686-w64-mingw32-gcc supports -c -o file.o... (cached) yes checking whether the i686-w64-mingw32-gcc linker (/usr/bin/i686-w64-mingw32-ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for i686-w64-mingw32-as... i686-w64-mingw32-as checking for i686-w64-mingw32-dlltool... (cached) i686-w64-mingw32-dlltool checking for i686-w64-mingw32-objdump... (cached) i686-w64-mingw32-objdump checking for flex... flex checking lex output file root... lex.yy checking lex library... none needed checking whether yytext is a pointer... no checking for bison... bison -y checking return type of signal handlers... void checking stdarg.h usability... yes checking stdarg.h presence... yes checking for stdarg.h... yes checking for sys/types.h... (cached) yes checking dirent.h usability... yes checking dirent.h presence... yes checking for dirent.h... yes checking errno.h usability... yes checking errno.h presence... yes checking for errno.h... yes checking libgen.h usability... yes checking libgen.h presence... yes checking for libgen.h... yes checking malloc.h usability... yes checking malloc.h presence... yes checking for malloc.h... yes checking for stdlib.h... (cached) yes checking mntent.h usability... no checking mntent.h presence... no checking for mntent.h... no checking linux/cdrom.h usability... no checking linux/cdrom.h presence... no checking for linux/cdrom.h... no checking for inttypes.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking time.h usability... yes checking time.h presence... yes checking for time.h... yes checking sys/select.h usability... no checking sys/select.h presence... no checking for sys/select.h... no checking limits.h usability... yes checking limits.h presence... yes checking for limits.h... yes checking sys/param.h usability... yes checking sys/param.h presence... yes checking for sys/param.h... yes checking sys/mount.h usability... no checking sys/mount.h presence... no checking for sys/mount.h... no checking for dirent.h that defines DIR... yes checking for library containing opendir... none required checking for struct dirent.d_type... no checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... 64 checking for snprintf... yes checking for i686-w64-mingw32-libgcrypt-config... no checking for libgcrypt-config... /usr/bin/libgcrypt-config checking for LIBGCRYPT - version >= 1.6.0... yes (1.6.1) /usr/bin/libgcrypt-config: 1: /usr/bin/libgcrypt-config: dpkg-architecture: not found configure: WARNING: *** *** The config script /usr/bin/libgcrypt-config was *** built for i686-pc-linux-gnu and thus may not match the *** used host i686-w64-mingw32. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script. *** checking whether strerror_r is declared... no checking for strerror_r... no checking whether strerror_r returns char *... no checking for i686-w64-mingw32-gpg-error-config... no checking for gpg-error-config... /usr/bin/gpg-error-config checking for GPG Error - version >= 0.5... yes (1.12) configure: WARNING: *** *** The config script /usr/bin/gpg-error-config was *** built for i686-pc-linux-gnu and thus may not match the *** used host i686-w64-mingw32. *** You may want to use the configure option --with-gpg-error-prefix *** to specify a matching config script. *** checking if i686-w64-mingw32-gcc supports -Wall flag... yes checking if i686-w64-mingw32-gcc supports -Wdisabled-optimization flag... yes checking if i686-w64-mingw32-gcc supports -Wpointer-arith flag... yes checking if i686-w64-mingw32-gcc supports -Wredundant-decls flag... yes checking if i686-w64-mingw32-gcc supports -Wcast-qual flag... yes checking if i686-w64-mingw32-gcc supports -Wwrite-strings flag... yes checking if i686-w64-mingw32-gcc supports -Wtype-limits flag... yes checking if i686-w64-mingw32-gcc supports -Wundef flag... yes checking if i686-w64-mingw32-gcc supports -Wmissing-prototypes flag... yes checking if i686-w64-mingw32-gcc supports -Wshadow flag... yes checking if i686-w64-mingw32-gcc supports -Werror=implicit-function-declaration flag... yes checking for i686-w64-mingw32-gcc way to treat warnings as errors... -Werror checking if i686-w64-mingw32-gcc supports -Wextra flag... yes checking if i686-w64-mingw32-gcc supports -Winline flag... yes checking if i686-w64-mingw32-gcc supports -O3 flag... yes checking if i686-w64-mingw32-gcc supports -fomit-frame-pointer flag... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating src/libaacs.pc config.status: creating src/libaacs/aacs-version.h config.status: creating config.h config.status: config.h is unchanged config.status: executing depfiles commands config.status: executing libtool commands root@test-VirtualBox:/home/test/libaacs-0.8.1#
For both libgcrypt and gpg I get the warning that they do not match (or support) to specified host 'i686-w64-mingw32' - is this my problem? And in case it is - how can I resolve it?

Thanks for your help! Unfortunately I'm quite a newbie when it comes to compiling something :-|

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: problems when cross-compiling libaacs for windows in ubuntu

Postby Rémi Denis-Courmont » 09 Jul 2015 22:44

Yes, that is your problem.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

nalor
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Jul 2015 20:57

Re: problems when cross-compiling libaacs for windows in ubuntu

Postby nalor » 10 Jul 2015 11:28

Thanks for your answer - but how can I solve my problem?

Other people also managed to compile libaacs for windows - so there has to be a way to do this.

In case you think cross-compiling in linux for windows is not the right way I'd be grateful if you could lead me into the right direction...

Thanks in advance!

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: problems when cross-compiling libaacs for windows in ubuntu

Postby Rémi Denis-Courmont » 10 Jul 2015 11:33

I would check the configure help. You are probably missing some parameter here.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

nalor
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Jul 2015 20:57

Re: problems when cross-compiling libaacs for windows in ubuntu

Postby nalor » 28 Jul 2015 14:34

Back from my vacation - and finally I managed to compile libaacs :)

Basically libaacs needs libgcrypt, and libgcrypt needs gpg-error - but the special thing here is that it is necessary to also use a cross-compiled build of the latest 2 packages! So my first try to simply make 'apt-get install libgcrypt...' has been totally wrong.

So I had to build them myself with this commands:

Code: Select all

mkdir ~/compile cd ~/compile curl ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.19.tar.bz2 | tar xvj cd libgpg-error-1.19/ ./autogen.sh --build-w32 make make install cd .. curl ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.3.tar.bz2 | tar xvj cd libgcrypt-1.6.3/ ./autogen.sh --build-w32 make make install cd ..
Now the files are all in the folder '/root/w32root'

And finally it's possible to compile libaacs and use the files in this folder:

Code: Select all

curl ftp://ftp.videolan.org/pub/videolan/libaacs/0.8.1/libaacs-0.8.1.tar.bz2 | tar xvj cd libaacs-0.8.1/ ./configure --host=i686-w64-mingw32 --with-libgcrypt-prefix=/root/w32root --with-gpg-error-prefix=/root/w32root make make install cd ..
the last part is to copy all necessary files in one folder to make it easier to transfer them to windows:

Code: Select all

mkdir win_libaacs cd win_libaacs/ cp ~/compile/libaacs-0.8.1/parser_test.exe ./ cp /usr/local/bin/aacs_info.exe ./ cp /usr/local/bin/libaacs-0.dll ./ cp /root/w32root/bin/libgcrypt-20.dll ./ cp /root/w32root/bin/libgpg-error-0.dll ./
Hope this helps other users too :)

In the end the build process for all packages takes less than 5 minutes... it's only a matter of knowing what to do :)

nalor
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Jul 2015 20:57

Re: problems when cross-compiling libaacs for windows in ubuntu

Postby nalor » 22 Oct 2015 22:24

Tried to compile the x64 binaries for windows and finally managed to succeed :)

Install the x64 tools as noted on the wiki page (in addition to the other tools installed before)

Code: Select all

apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
I also learned it's a lot easier if you create a new directory for the compile-process:

Code: Select all

mkdir /libaacscompile mkdir /libaacscompile/install64 cd /libaacscompile
Compile libgpg-error:

Code: Select all

curl ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.20.tar.bz2 | tar xvj cd libgpg-error-1.20/ ./autogen.sh --build-w64 --prefix=/libaacscompile/install64/ make make install cd ..
Compile libgcrypt

Code: Select all

curl ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.4.tar.bz2 | tar xvj cd libgcrypt-1.6.4/ apply this patch here: [url]http://lists.freedesktop.org/archives/gstreamer-commits/2014-February/077093.html[/url] >> this basically means to edit the file random/rndhw.c, search for '&& defined(__LP64__)' and insert '//' in front of it - this has to be done 2 times in the file ./configure --host=x86_64-w64-mingw32 --disable-asm --with-gpg-error-prefix=/libaacscompile/install64 --prefix=/libaacscompile/install64 make make install cd ..
Compile Libaacs

Code: Select all

curl ftp://ftp.videolan.org/pub/videolan/libaacs/0.8.1/libaacs-0.8.1.tar.bz2 | tar xvj cd libaacs-0.8.1/ ./configure --host=x86_64-w64-mingw32 --with-libgcrypt-prefix=/libaacscompile/install64 --with-gpg-error-prefix=/libaacscompile/install64 --prefix=/libaacscompile/install64 make make install cd ..
You can find all created files in the directory /libaacscompile/install64/bin, basically you need the following:
  • libaacs-0.dll
  • libgcrypt-20.dll
  • libgpg-error6-0.dll
  • aacs_info.exe (is not directly necessary, but with this file you can test the compiled library without any additional tools)

nalor
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Jul 2015 20:57

Re: problems when cross-compiling libaacs for windows in ubuntu

Postby nalor » 04 Nov 2015 21:00

Learned a few things in the last couple of days:

it's more convenient to set the directory for the final files as environment variable and simply use the environment-variable when specifying the prefix-values
export BUILDDIR=/libaacscompile/install_x64
when compiling libgcrypt it's not necessary to include all supported encryption standards - so the following configure command includes everything necessary for libaacs and creates a smaller dll-file:
./configure --host=i686-w64-mingw32 --prefix=$BUILDDIR/ --with-gpg-error-prefix=$BUILDDIR --enable-ciphers=aes --enable-pubkey-ciphers=ecc --enable-digests=sha1 --enable-random=w32 --enable-kdfs=pkdf2 --disable-padlock-support --enable-threads=windows
And for 64 bit builds it's not necessary to edit the rndhw.c file any longer:
./configure --host=x86_64-w64-mingw32 --prefix=$BUILDDIR/ --with-gpg-error-prefix=$BUILDDIR/ --enable-ciphers=aes --enable-pubkey-ciphers=ecc --enable-digests=sha1 --enable-random=w32 --enable-kdfs=pkdf2 --disable-padlock-support --enable-threads=windows --disable-asm
Finally it's a good idea to 'strip' the compiled files to remove debug information not necessary for the common user:
strip -s /libaacscompile/install_x64/bin/*
This last step reduces the filesize a lot! (from 5MB to 500KB)


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests