For cross-compilation for WIndows What's the best way to do it?

This forum is about all development around libVLC.
Yothuba
New Cone
New Cone
Posts: 2
Joined: 08 May 2020 04:42

For cross-compilation for WIndows What's the best way to do it?

Postby Yothuba » 08 May 2020 05:00

I have been struggling to cross-compile VLC3.0 since about a week ago, and I feel that the Wiki method does not work in most cases.
I don't want to be bothered by the many errors caused by minor environmental differences any more. Isn't there a way to ensure success?

ayushs
New Cone
New Cone
Posts: 1
Joined: 17 May 2020 22:47

Re: For cross-compilation for WIndows What's the best way to do it?

Postby ayushs » 18 May 2020 09:50

I was able to compile 32 bit version, but faced relocation errors with 64 bit version. There is a bug in the default gcc-mingw-w64-x86-64 ubuntu package version, which is fixed in later versions ->

http://trac.ffmpeg.org/ticket/5895
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85298

You can obviously use the docker image suggested in this forum, but i decided to build the cross-compiler for 64 bit on my system.

This is for vlc 3.0.8. Should work on others as well.

Start by installing the deps.
Only mingw-w64-tools and not gcc-mingw-w64-x86-64 and g++-mingw-w64-x86-64.
Leave out qt, protobuf. It is there is vlc contribs or tools.

Code: Select all

# apt-get install mingw-w64-tools # apt-get install lua5.2 libtool automake autoconf autopoint make gettext pkg-config # apt-get install git subversion cmake cvs # apt-get install wine64-development-tools libwine-dev zip p7zip nsis bzip2 # apt-get install yasm ragel ant default-jdk dos2unix

To build the toolchain, the steps are given in the mingw docs, but i will list it out ->

VERSION:
binutils : 2.28
gcc : 8.3.0
mingw64 : 7.0.0

Binutils
download from -> https://mirror.freedif.org/GNU/binutils/

Code: Select all

mkdir build && cd build ../configure --target=x86_64-w64-mingw32 --disable-multilib make -j4 make install

Headers
Download mingw -> https://sourceforge.net/p/mingw-w64/

Code: Select all

cd mingw-w64/mingw-w64-headers mkdir build && cd build ../configure --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32 --prefix=/usr/local/x86_64-w64-mingw32 make install ln -s /usr/local/x86_64-w64-mingw32 /usr/local/mingw mkdir -p /usr/local/x86_64-w64-mingw32/lib ln -s /usr/local/x86_64-w64-mingw32/lib /usr/local/x86_64-w64-mingw32/lib64

GCC core
Download -> https://mirror.ossplanet.net/gnu/gcc/gcc-8.3.0/

Code: Select all

./contrib/download_prerequisites mkdir build && cd build ../configure --target=x86_64-w64-mingw32 --disable-multilib --disable-shared make all-gcc -j4 make install-gcc

Mingw crt

Code: Select all

cd mingw-w64/mingw-w64-crt mkdir build && cd build ../configure --host=x86_64-w64-mingw32 --prefix=/usr/local/x86_64-w64-mingw32 make -j4 make install

Make sure you have the following directories in the directory you have installed the mingw-w64 toolchain to:

Code: Select all

<root>/x86_64-w64-mingw32 <root>/x86_64-w64-mingw32/include <root>/x86_64-w64-mingw32/lib <root>/x86_64-w64-mingw32/lib32 <root>/x86_64-w64-mingw32/lib64 [link to lib] <root>/mingw [link to x86_64-w64-mingw32] <root>/mingw/include <root>/mingw/lib <root>/mingw/lib32 <root>/mingw/lib64 [link to lib]

go back to gcc folder ...


GCC main

Code: Select all

cd gcc/build make -j4 make install

Now that your cross-compiler is built, you can start building VLC ->

WIN 64 compile:

Tools:

Code: Select all

cd extras/tools/ make -j4

Contribs:

Code: Select all

mkdir -p contrib/win64 cd contrib/win64 ../bootstrap --host=x86_64-w64-mingw32 make fetch && make rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc ln -sf 'x86_64-w64-mingw32' ../i686-w64-mingw32

VLC main:

Code: Select all

cd ../../ ./bootstrap mkdir win64 && cd win64 export PKG_CONFIG_LIBDIR=<path-to-vlc-dir>/contrib/x86_64-w64-mingw32/lib/pkgconfig/ export PKG_CONFIG_PATH_CUSTOM=$PKG_CONFIG_LIBDIR ../extras/package/win32/configure.sh --host=x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu make -j4

now build packages ->

Code: Select all

make package-win-common

This worked for me. Hope this helps you and others.


Some other errors i faced. If you need ->


1. update glew 2.1.0 in rules.mk

Code: Select all

make[1]: recipe for target '.glew' failed make: *** [.glew] Error 2


2. Dll plugin not found
https://forum.videolan.org/viewtopic.php?t=145409
https://forum.videolan.org/viewtopic.php?t=108669

Code: Select all

I modified contrib/src/d3d11/rules.mak and contrib/src/d3d9/rules.mak. ==================================================== ifdef HAVE_CROSS_COMPILE IDL_INC_PATH = /usr/include/wine/windows/ else #ugly way to get the default location of standard idl files IDL_INC_PATH = /`echo $(MSYSTEM) | tr A-Z a-z`/$(BUILD)/include endif +IDL_INC_PATH = /usr/include/wine-development/windows/

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

Re: For cross-compilation for WIndows What's the best way to do it?

Postby Rémi Denis-Courmont » 18 May 2020 17:40

I have been struggling to cross-compile VLC3.0 since about a week ago, and I feel that the Wiki method does not work in most cases.
I don't want to be bothered by the many errors caused by minor environmental differences any more. Isn't there a way to ensure success?
We can't exactly prevent differences between different distributions and between different versions of the same distribution. There is a way to ensure success: have somebody else do and document it, and reproduce exactly their setup. What else do you expect?
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

alex4801
New Cone
New Cone
Posts: 8
Joined: 22 May 2014 19:03

Re: For cross-compilation for WIndows What's the best way to do it?

Postby alex4801 » 04 Jun 2020 05:27

Yothuba,

Here is the information you seek. With these simple steps you eliminate any variability in the hardware and software configuration, ensuring success:

1. Create an Amazon AWS account and deploy one of their EC2 Linux 2 instances. Configure it with 16 GB of storage. They make this very easy to do and can be done in 15 minutes. Use their c5.12xlarge instance type, which costs about $2 per hour. Smaller instances cost as little as 8 cents per hour.

2. Log in (via ssh) to the Linux instance you just deployed and install (1) docker and (2) git. They have very simple instructions on how to do this. Just google "aws ec2 install docker" and "aws ec2 install git". It will take 5 minutes.

3. Clone the VLC repo. This will only take a couple minutes.

Code: Select all

git clone git://git.videolan.org/vlc/vlc-3.0.git

4. Run the docker.

Code: Select all

sudo docker run --rm -it -v /home/ec2-user/vlc-3.0:/vlc registry.videolan.org:5000/vlc-debian-win32:latest /bin/bash

5. On the docker, run the build script:

Code: Select all

cd vlc && extras/package/win32/build.sh -a i686 -r

6. Wait about 15 minutes. The 48-vCPU c5.12xlarge EC2 instance will build the entire codebase including contribs and the ZIP file in less than 15 minutes, which will be located here:

Code: Select all

win32/vlc-3.0.11-win32.zip

7. Stop the EC2 instance so that you aren't charged for it any more.

Good luck, but you probably won't need it.

-Alex

Yothuba
New Cone
New Cone
Posts: 2
Joined: 08 May 2020 04:42

Re: For cross-compilation for WIndows What's the best way to do it?

Postby Yothuba » 04 Jun 2020 08:55

Oh, thank you everyone.
I apologize for the delay in replying. To be honest, I didn't think there was a solution, so I'm very happy that you presented several methods.
I'm going to try everything here.
Thank you. I'm sorry that my English is not good.

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: For cross-compilation for WIndows What's the best way to do it?

Postby unidan » 22 Jun 2020 16:10

Hi, you can also use the docker method on windows, without starting a remote EC2 instance. By using the version currently in place in the CI, you more or less maximize your chances of successful compilation.

User avatar
andrelcm
New Cone
New Cone
Posts: 3
Joined: 15 Oct 2020 02:11

Re: For cross-compilation for WIndows What's the best way to do it?

Postby andrelcm » 24 Oct 2020 03:45

I tried the above method, but I've got these errors below. Can someone help me?

Code: Select all

cd harfbuzz && make install make[1]: Entering directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz' Making install in src make[2]: Entering directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src' make install-recursive make[3]: Entering directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src' make[4]: Entering directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src' CXXLD main.exe /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-blob.o): in function `hb_mutex_t::lock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:120: undefined reference to `pthread_mutex_lock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-blob.o): in function `hb_mutex_t::unlock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:121: undefined reference to `pthread_mutex_unlock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-blob.o): in function `hb_mutex_t::lock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:120: undefined reference to `pthread_mutex_lock' (.....) /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::lock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:120: undefined reference to `pthread_mutex_lock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::unlock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:121: undefined reference to `pthread_mutex_unlock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::fini()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:122: undefined reference to `pthread_mutex_destroy' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::lock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:120: undefined reference to `pthread_mutex_lock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::unlock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:121: undefined reference to `pthread_mutex_unlock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::lock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:120: undefined reference to `pthread_mutex_lock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::unlock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:121: undefined reference to `pthread_mutex_unlock' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::fini()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:122: undefined reference to `pthread_mutex_destroy' /usr/bin/x86_64-w64-mingw32-ld: /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:122: undefined reference to `pthread_mutex_destroy' /usr/bin/x86_64-w64-mingw32-ld: ./.libs/libharfbuzz.a(libharfbuzz_la-hb-ot-shape-complex-arabic.o): in function `hb_mutex_t::unlock()': /home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src/hb-mutex.hh:121: undefined reference to `pthread_mutex_unlock' collect2: error: ld returned 1 exit status make[4]: *** [Makefile:1807: main.exe] Error 1 make[4]: Leaving directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src' make[3]: *** [Makefile:2994: install-recursive] Error 1 make[3]: Leaving directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src' make[2]: *** [Makefile:3413: install] Error 2 make[2]: Leaving directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz/src' make[1]: *** [Makefile:517: install-recursive] Error 1 make[1]: Leaving directory '/home/andre/workspace/novo/vlc-3.0.11/contrib/win32/harfbuzz' make: *** [../../contrib/src/harfbuzz/rules.mak:32: .harfbuzz] Error 2


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 11 guests