Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compiler error on Mac of missing endian.h #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chundongwang
Copy link

Originally if you compile untrunc on mac, you'll get track.cpp:28:10: fatal error: 'endian.h' file not found. But even if you switch to <machine/endian.h>, it'll still complain about file.cpp:74:12: error: use of undeclared identifier 'be32toh'.

So solution is to provide be32toh with OSSwapBigToHostInt32, and so on. For windows we might have to implement ourselves but I'll leave it to someone really needs windows support to implement this.

chundongwang and others added 3 commits May 18, 2016 23:30
Libav[1] has change the function avcodec_alloc_frame to av_frame_alloc.
This fix is required to build untrunc with latest libav

[1]https://patches.libav.org/patch/44214/
Fix deprecated libav function on MacOS
Copy link
Owner

@ponchio ponchio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the huge delay, I have removed the endian.h dependency and updated the avcodec api.

Would you mind gettin gthe latest version so I can merge the docs?

@jmoleiro
Copy link

Hi! To get it compiled, i commented the includes for endian.h. Also i have to reference CoreFoundation and CoreVideo to fix some symbol references. This is the command line i've used on OSX 10.12.6

g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -I./libav-12.2 -L./libav-12.2/libavformat -lavformat -L./libav-12.2/libavcodec -lavcodec -L./libav-12.2/libavresample -lavresample -L./libav-12.2/libavutil -lavutil -lpthread -lz -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration -lbz2

@ghost
Copy link

ghost commented Mar 31, 2018

Hi, was the dependency on endian.h really removed? I still have to "sed -i.orig -e's:endian.h:machine/endian.h:' *cpp" to make it compile.

@selecgo
Copy link

selecgo commented Apr 25, 2018

Hi, I get the track.cpp:46:10: fatal error: 'config.h' file not found after solving the endian.h dependency with mike402's "sed -i.orig -e's:endian.h:machine/endian.h:' *cpp".

Here is my folder for reference and fixing. https://drive.google.com/open?id=11Jr-KXLXR8y3AITcIKdW4CuwUj__ShIf
Thanks!

Used jmoleiro's suggestion for the compile command.
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -I./libav-12.2 -L./libav-12.2/libavformat -lavformat -L./libav-12.2/libavcodec -lavcodec -L./libav-12.2/libavresample -lavresample -L./libav-12.2/libavutil -lavutil -lpthread -lz -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration -lbz2

track.cpp:30:9: warning: '__STDC_LIMIT_MACROS' macro redefined
[-Wmacro-redefined]
#define __STDC_LIMIT_MACROS 1
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdint.h:113:12: note:
previous definition is here

define __STDC_LIMIT_MACROS

       ^

track.cpp:31:9: warning: '__STDC_CONSTANT_MACROS' macro redefined
[-Wmacro-redefined]
#define __STDC_CONSTANT_MACROS 1
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdint.h:116:12: note:
previous definition is here

define __STDC_CONSTANT_MACROS

       ^

track.cpp:46:10: fatal error: 'config.h' file not found
#include <config.h>
^~~~~~~~~~
2 warnings and 1 error generated.
mp4.cpp:25:9: warning: '__STDC_LIMIT_MACROS' macro redefined [-Wmacro-redefined]
#define __STDC_LIMIT_MACROS 1
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdint.h:113:12: note:
previous definition is here

define __STDC_LIMIT_MACROS

       ^

mp4.cpp:26:9: warning: '__STDC_CONSTANT_MACROS' macro redefined
[-Wmacro-redefined]
#define __STDC_CONSTANT_MACROS 1
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdint.h:116:12: note:
previous definition is here

define __STDC_CONSTANT_MACROS

       ^

mp4.cpp:71:2: warning: 'av_register_all' is deprecated
[-Wdeprecated-declarations]
av_register_all();
^
/usr/local/include/libavformat/avformat.h:2024:1: note: 'av_register_all' has
been explicitly marked deprecated here
attribute_deprecated
^
/usr/local/include/libavutil/attributes.h:94:49: note: expanded from macro
'attribute_deprecated'

define attribute_deprecated attribute((deprecated))

                                            ^

mp4.cpp:285:46: warning: 'codec' is deprecated [-Wdeprecated-declarations]
track.codec.context = context->streams[i]->codec;
^
/usr/local/include/libavformat/avformat.h:876:5: note: 'codec' has been
explicitly marked deprecated here
attribute_deprecated
^
/usr/local/include/libavutil/attributes.h:94:49: note: expanded from macro
'attribute_deprecated'

define attribute_deprecated attribute((deprecated))

@pineapplejoe
Copy link

Yeah -definitely not working on Mac anymore.

track.cpp:197:12: error: out-of-line definition of 'getLength' does not match any declaration in 'Codec'
int Codec::getLength(unsigned char *start, int maxlength) {

track.cpp:385:59: error: no member named 'codec_name' in 'AVCodecContext'
throw string("Could not open codec: ") + codec.context->codec_name;

among a slew of warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants