untrunc
untrunc copied to clipboard
endian.h and compiling for Windows
I'm trying to compile untrunc for windows. I've been successful in using cygwin to do this but not using mingw-w64 or using cross compilation. I keep getting endian.h errors and when I try to include them or their library I get double declaration errors. Any suggestions ? Thank you.
Yes, crossplatform endian.h are exist, but after that you will get undefined uint.
@CoderBlue what changes required to build for for windows? current Master branch doesn't seem to build. i built 12.3 libav using mingw on windows 10 64bit,
then when running below command using cygwin(or msys or mingw). it's throwing error for pthreads
g++ -o untrunc -I./libav-12.3 file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L./libav-12.3/libavformat -lavformat -L./libav-12.3/libavcodec -lavcodec -L./libav-12.3/libavresample -lavresample -L./libav-12.3/libavutil -lavutil -lpthread -lz
i tried removing -lpthread, but no luck
In file included from ./libav-12.3/libavutil/thread.h:32:0,
from ./libav-12.3/libavcodec/h264dec.h:33,
from track.cpp:52:
./libav-12.3/compat/w32pthreads.h:51:16: error: using typedef-name ‘pthread_t’ after ‘struct’
typedef struct pthread_t {
^~~~~~~~~
and many conflicting declaration , one such is below
In file included from ./libav-12.3/libavutil/thread.h:32:0,
from ./libav-12.3/libavcodec/h264dec.h:33,
from track.cpp:52:
./libav-12.3/compat/w32pthreads.h:60:26: error: conflicting declaration ‘typedef CRITICAL_SECTION pthread_mutex_t’
typedef CRITICAL_SECTION pthread_mutex_t;
^~~~~~~~~~~~~~~
gist of other errors:
In file included from ./libav-12.3/libavutil/thread.h:32:0,
from ./libav-12.3/libavcodec/h264dec.h:33,
from track.cpp:52:
./libav-12.3/compat/w32pthreads.h: In function ‘unsigned int win32thread_worker(void*)’:
./libav-12.3/compat/w32pthreads.h:79:20: error: invalid conversion from ‘void*’ to ‘__pthread_t**’ [-fpermissive]
pthread_t *h = arg;
^~~
./libav-12.3/compat/w32pthreads.h:80:8: error: request for member ‘ret’ in ‘* h’, which is of pointer type ‘pthread_t {aka __pthread_t*}’ (maybe you meant to use ‘->’ ?)
h->ret = h->func(h->arg);
^~~
./libav-12.3/compat/w32pthreads.h:80:17: error: request for member ‘func’ in ‘* h’, which is of pointer type ‘pthread_t {aka __pthread_t*}’ (maybe you meant to use ‘->’ ?)
h->ret = h->func(h->arg);
^~~~
./libav-12.3/compat/w32pthreads.h:80:25: error: request for member ‘arg’ in ‘* h’, which is of pointer type ‘pthread_t {aka __pthread_t*}’ (maybe you meant to use ‘->’ ?)
h->ret = h->func(h->arg);
i've attached entire log output.log
build succeeds in ubuntu 18.04 LTS, so i tried to cross-compile for windows from ubuntu using mingw 64bit.. it didn't work either.
it says <feature.h> not found..so when i include -I/usr/include/ like below
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil -L/usr/lib/x86_64-linux-gnu -I/usr/inlcude/
it throws too many conflicting declaration.
@ponchio might be knowing to fix this?
Thanks & Regards Prakash
@Prakash19921206 iirc you have to choose the pthread threading model when installing cygwin.
@anthwlock , Thanks for your reply. initially i had only installed default package, then i installed all packages.. still no changes in build output. below is the snapshot of pthreads version installed
I don't know about cygwin, but I was able to build untrunc on windows using mingw-w64.
On install mingw-w64 asks your preferred threading model:

Eventually you will have more luck cross-compiling using this branch of untrunc. Otherwise your problem seems not to be related to untrunc, but cygwin in general.
@anthwlock, Thanks for your reply. for this repository, windows build succeeded. after installing all packages in cygwin i installed NASM and YASM and added its path to environment variable(PATH)
then build libav-12.3 using mingw using
./configure --enable-pthreads --enable-shared
and make command using cygwin
finally using cygwin i used below command
g++ -o untrunc -I./libav-12.3 file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L./libav-12.3/libavformat -lavformat -L./libav-12.3/libavcodec -lavcodec -L./libav-12.3/libavresample -lavresample -L./libav-12.3/libavutil -lavutil -lpthread -lz
now there is a different issue. not really an issue but missing feature may be!
this repository takes around 30seconds to fix 5 min video. but your repository takes only couple of seconds (checked on ubuntu but still unable to build your repo on windows)
i think new version is modified, couldn't locate posix or pthreads, but found winpthreads(which is not required i suppose?)
having other issues in building your repository on windows. continuing the issue there Thanks & Regards Prakash
Edit: I guess this issue can be closed now, as on windows build succeeds..
Note: Automated builds are now available here.