Page 1 of 1

Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 03 Aug 2016 22:10
by richardy
I am trying to cross compile for Windows on a Debian VM running on Macbook Pro. I am using the instructions from https://wiki.videolan.org/Win32Compile/.

At first I encountered the mkstemp error reported here: https://forum.videolan.org/viewtopic.ph ... ws#p443926
I built mingw64 using version 5.3 and after a little fiddling got past the mkstemp issue. However I ran into this exception and do not have a clue about how to fix it.

Code: Select all

CC       demux/avformat/libavcodec_plugin_la-mux.lo   CCLD     libavcodec_plugin.la /opt/gcc-x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lpthread collect2: error: ld returned 1 exit status Makefile:10175: recipe for target 'libavcodec_plugin.la' failed make[4]: *** [libavcodec_plugin.la] Error 1 make[4]: Leaving directory '/home/deb/vlc/win32/modules' Makefile:18624: recipe for target 'all-recursive' failed make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory '/home/deb/vlc/win32/modules' Makefile:8284: recipe for target 'all' failed make[2]: *** [all] Error 2 make[2]: Leaving directory '/home/deb/vlc/win32/modules' Makefile:2252: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/deb/vlc/win32' Makefile:2136: recipe for target 'all' failed make: *** [all] Error 2 deb@debmac:~/vlc/win32$ 
Any help is appreciated.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 04 Aug 2016 16:40
by Jean-Baptiste Kempf
You need to recompile the contribs.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 04 Aug 2016 21:50
by richardy
I very much appreciate your quick response.
When I compile the contribs, make exits with this log entry:

Code: Select all

CC contrib/libudfread/src/udfread.lo contrib/libudfread/src/udfread.c: In function '_find_file': contrib/libudfread/src/udfread.c:37:18: error: implicit declaration of function 'strtok_s' [-Werror=implicit-function-declaration] #define strtok_r strtok_s ^ contrib/libudfread/src/udfread.c:1033:13: note: in expansion of macro 'strtok_r' token = strtok_r(tmp_path, "/\\", &save_ptr); ^ contrib/libudfread/src/udfread.c:1033:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion] token = strtok_r(tmp_path, "/\\", &save_ptr); ^ contrib/libudfread/src/udfread.c:1047:15: warning: assignment makes pointer from integer without a cast [-Wint-conversion] token = strtok_r(NULL, "/\\", &save_ptr); ^ cc1: some warnings being treated as errors Makefile:1490: recipe for target 'contrib/libudfread/src/udfread.lo' failed make[1]: *** [contrib/libudfread/src/udfread.lo] Error 1 make[1]: Leaving directory '/home/deb/vlc/contrib/win32/bluray' ../../contrib/src/bluray/rules.mak:50: recipe for target '.bluray' failed make: *** [.bluray] Error 2
Is this a problem with my compiler, the source code or something else I have failed to do?

All help is greatly appreciated.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 06 Aug 2016 11:37
by Jean-Baptiste Kempf
You need to reocmpile the contribs or update your compiler.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 09 Aug 2016 00:40
by richardy
Thanks for the help. I must have missed something building the compiler. I re-compiled it and tried again to compile the contribs.

I encountered the exact same error reported in this thread: https://forum.videolan.org/viewtopic.ph ... 69#p446569. The poster in that thread identified the issue as being a Wine problem but I am at a loss to know how to fix it.

Any help, insight or guidance is appreciated.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 09 Aug 2016 10:42
by Jean-Baptiste Kempf
You need to install wine-tools, I believe.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 09 Aug 2016 21:13
by richardy
When I started, the instructions suggested installing wine-dev. I could not find a Debian package called wine-dev but there is one wine-development, so I installed it. Since reading your last post, I have looked without success for a wine-tools package but there are a lot of wine64 packages that have "tool" or "development" in the name. I installed them all (which might have done more harm than good :)

Anyway, the process of building the contribs still breaks in the same place with the same error message:

Code: Select all

mkdir -p dxgi12 cp ../../contrib/tarballs/dxgi1_2.idl dxgi12 && cd dxgi12 && patch -fp1 < ../../../contrib/src/d3d11/dxgi12.patch patching file dxgi1_2.idl mkdir -p -- "/home/deb/vlc/contrib/x86_64-w64-mingw32/include/" x86_64-w64-mingw32-widl -DBOOL=WINBOOL -I/usr/include/wine/windows/ -h -o /home/deb/vlc/contrib/x86_64-w64-mingw32/include/dxgi1_2.h dxgi12/dxgi1_2.idl dxgi12/dxgi1_2.idl:43: error: syntax error, unexpected aKNOWNTYPE, expecting tIMPORT ../../contrib/src/d3d11/rules.mak:63: recipe for target '/home/deb/vlc/contrib/x86_64-w64-mingw32/include/dxgi1_2.h' failed make: *** [/home/deb/vlc/contrib/x86_64-w64-mingw32/include/dxgi1_2.h] Error 1
Thanks.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 18 Aug 2016 21:15
by richardy
I am able to cross compile VLC for Windows with a big thank you to @runner0502. See this thread: https://forum.videolan.org/viewtopic.ph ... 21#p447021

In the hope that it will help someone else here is a summary of the steps I took to cross compile VLC for Windows. Generally, I followed the instructions here https://wiki.videolan.org/Win32Compile/ but with the following adjustments/additions

1. I am using Ubuntu 16.04 running in a VM hosted on a MacBook Pro
2. $> sudo apt-get install lua5.1 libtool automake autoconf autopoint make gettext pkg-config git subversion cmake cvs zip p7zip-full nsis bzip2 protobuf-compiler tofrodos
3. $> sudo apt-get install gcc-mingw-w64 g++-mingw-w64 mingw-w64-tools
Earlier in this thread and in other threads concerning cross sompiling for Windows, it is suggested that mingw64 version 5 is required and that in order to get version 5+ one must either use an experimental package or build mingw from latest source. As of this post, the above commands installed version 5.
4. I needed to uninstall qt4 stuff (you may not have all of these): $> sudo apt-get remove --purge qt4-default qt4-designer qt4-dev-tools qt4-make qt4-doc qt4-linguist-tools qtchooser
5. I needed to install qt5 stuff: $> sudo apt-get install qt5-qmake qt5-default qttools5-dev-tools libqt5script5 libqt5scripttools5 qtscript5-dev
6. Follow the instructions for cloning the repository
7. I needed to compile the contribs - some additional steps are required
8. $> sudo apt-get install ragel yasm ant default-jdk wine64-development-tools
9. $> cd vlc && mkdir -p contrib/win32 && cd contrib/win32
10. $> ../bootstrap --host=x86_64-w64-mingw32 <Use appropriate triple for your requirements>
11. $> make fetch
12. edit ..\src\d3d9\rules.mak and ..\src\d3d11\rules.mak IDL_INC_PATH = /usr/include/wine/windows/ to IDL_INC_PATH = /usr/include/wine-development/windows/
13. $> make
14. Get an adult beverage, take a break and come back in an hour or two (your mileage will differ)
15. Once the contribs are compiled you should be ok to follow the rest of the instructions. Don't forget the Linux 64 bit section
16. The only other issue I had was when packaging VLC using package-win-common I needed to edit the Makefile to use todos and remove the -q argument. The Makefile was calling unix2dos -q to modify the line endings on txt, xml and other file types. My Ubuntu does not have unix2dos so I needed to install the tofrodos package and alter the Makefile.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 21 Oct 2016 19:03
by oviano
I found this thread useful - thanks.

Here's a slightly refined set of steps which worked on freshly installed Ubuntu 16.04 VM on VMware Fusion on a Macbook Pro. These steps will build a 64-bit version for Windows.

sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
sudo apt-get install lua5.2
sudo apt-get install libtool automake autoconf autopoint make gettext
sudo apt-get install pkg-config
sudo apt-get install qt4-dev-tools qt5-default
sudo apt-get install git
sudo apt-get install subversion
sudo apt-get install cmake cvs
sudo apt-get install wine64-development-tools
sudo apt-get install zip p7zip nsis bzip2
sudo apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix

git clone http://git.videolan.org/git/vlc.git
cd vlc
mkdir -p contrib/win32
cd contrib/win32
../bootstrap --host=x86_64-w64-mingw32
make fetch
nano ../src/d3d9/rules.mak [manually change IDL_INC_PATH from wine to wine-development]
nano ../src/d3d11/rules.mak [manually change IDL_INC_PATH from wine to wine-development]
make
rm -f ../x86_64-w64-mingw32/bin/moc ../x86_64-w64-mingw32/bin/uic ../x86_64-w64-mingw32/bin/rcc
ln -sf x86_64-w64-mingw32 ../i686-w64-mingw32
cd ../..
./bootstrap
mkdir win32
cd win32
export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/x86_64-w64-mingw32/lib/pkgconfig
../extras/package/win32/configure.sh --host=x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu
make
make package-win-common

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 24 Oct 2016 21:45
by Jean-Baptiste Kempf
That should be good, indeed.

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 25 Oct 2016 08:20
by oviano
Further modified version including an optional line to tell it to build VLC against ffmpeg rather than libav. This solved an issue I was having where VLC wasn't able to decode videos encoded with yuv422p and yuv444p.

sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 -y
sudo apt-get install mingw-w64-tools -y
sudo apt-get install lua5.2 -y
sudo apt-get install libtool automake autoconf autopoint make gettext -y
sudo apt-get install pkg-config -y
sudo apt-get install qt4-dev-tools qt5-default -y
sudo apt-get install git -y
sudo apt-get install subversion -y
sudo apt-get install cmake cvs -y
sudo apt-get install wine64-development-tools -y
sudo apt-get install zip p7zip nsis bzip2 -y
sudo apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix -y

git clone http://git.videolan.org/git/vlc.git
cd vlc
nano contrib/src/ffmpeg/rules.mak [optional: manually uncomment the line "#USE_FFMPEG ?= 1" if you want to build VLC against ffmpeg instead of libav]
mkdir -p contrib/win64
cd contrib/win64
../bootstrap --host=x86_64-w64-mingw32
make fetch
nano ../src/d3d9/rules.mak [manually change IDL_INC_PATH from wine to wine-development]
nano ../src/d3d11/rules.mak [manually change IDL_INC_PATH from wine to wine-development]
make
rm -f ../x86_64-w64-mingw32/bin/moc ../x86_64-w64-mingw32/bin/uic ../x86_64-w64-mingw32/bin/rcc
ln -sf x86_64-w64-mingw32 ../i686-w64-mingw32
cd ../..
./bootstrap
mkdir win64
cd win64
export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/x86_64-w64-mingw32/lib/pkgconfig
../extras/package/win32/configure.sh --host=x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu
make
make package-win-common

Re: Cross Compile for Windows Fails: ld cannot find -lpthread

Posted: 18 Jan 2017 07:00
by priya_loke
Hi
I have been trying to cross compile VLC and have not been successful. I have followed the instructions posted in this thread and the wiki page. I still get this error:

Code: Select all

make[3]: Entering directory '/home/priya/vlc/contrib/win64/protobuf/src' protoc -I. --cpp_out=. google/protobuf/any_test.proto google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto google/protobuf/map_lite_unittest.proto google/protobuf/map_proto2_unittest.proto google/protobuf/map_unittest.proto google/protobuf/unittest_arena.proto google/protobuf/unittest_custom_options.proto google/protobuf/unittest_drop_unknown_fields.proto google/protobuf/unittest_embed_optimize_for.proto google/protobuf/unittest_empty.proto google/protobuf/unittest_enormous_descriptor.proto google/protobuf/unittest_import_lite.proto google/protobuf/unittest_import.proto google/protobuf/unittest_import_public_lite.proto google/protobuf/unittest_import_public.proto google/protobuf/unittest_lite_imports_nonlite.proto google/protobuf/unittest_lite.proto google/protobuf/unittest_mset.proto google/protobuf/unittest_mset_wire_format.proto google/protobuf/unittest_no_arena_lite.proto google/protobuf/unittest_no_arena_import.proto google/protobuf/unittest_no_arena.proto google/protobuf/unittest_no_field_presence.proto google/protobuf/unittest_no_generic_services.proto google/protobuf/unittest_optimize_for.proto google/protobuf/unittest_preserve_unknown_enum2.proto google/protobuf/unittest_preserve_unknown_enum.proto google/protobuf/unittest.proto google/protobuf/unittest_proto3_arena.proto google/protobuf/unittest_proto3_arena_lite.proto google/protobuf/unittest_proto3_lite.proto google/protobuf/unittest_well_known_types.proto google/protobuf/util/internal/testdata/anys.proto google/protobuf/util/internal/testdata/books.proto google/protobuf/util/internal/testdata/default_value.proto google/protobuf/util/internal/testdata/default_value_test.proto google/protobuf/util/internal/testdata/field_mask.proto google/protobuf/util/internal/testdata/maps.proto google/protobuf/util/internal/testdata/oneofs.proto google/protobuf/util/internal/testdata/proto3.proto google/protobuf/util/internal/testdata/struct.proto google/protobuf/util/internal/testdata/timestamp_duration.proto google/protobuf/util/internal/testdata/wrappers.proto google/protobuf/util/json_format_proto3.proto google/protobuf/util/message_differencer_unittest.proto google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto google/protobuf/any_test.proto:31:10: Unrecognized syntax identifier "proto3". This parser only recognizes "proto2". Makefile:7816: recipe for target 'unittest_proto_middleman' failed make[3]: *** [unittest_proto_middleman] Error 1 make[3]: Leaving directory '/home/priya/vlc/contrib/win64/protobuf/src' Makefile:1325: recipe for target 'all-recursive' failed make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory '/home/priya/vlc/contrib/win64/protobuf' Makefile:1232: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/home/priya/vlc/contrib/win64/protobuf' ../../contrib/src/protobuf/rules.mak:23: recipe for target '.protobuf' failed make: *** [.protobuf] Error 2
I am using a Windows 64 bit machine running an Ubuntu 16.04 (64-bit) VM. I am terribly stuck and have tried the same steps with an Ubuntu 32 bit VM, but in vain. Any help will greatly be appreciated.