将ffmpeg与C ++一起使用:架构x86_64的未定义符号

时间:2017-03-31 06:18:59

标签: c++ c ffmpeg

我正在处理一个名为FFMPEG的例子是" muxing.c"。

所以我尝试用两个Makefile编译该文件。第一个是C语言:

FFMPEG_LIBS=    libavdevice                        \
                libavformat                        \
                libavfilter                        \
                libavcodec                         \
                libswresample                      \
                libswscale                         \
                libavutil                          \

CFLAGS := -Wall -g $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) -lm $(LDLIBS)

SOURCES=        muxing                             \

OBJS=$(addsuffix .o,$(SOURCES))

all: $(OBJS) $(SOURCES)

makefile编译得很好。但是,如果我尝试将此代码移动到C ++:我将muxing.c重命名为muxing.cpp并使用此Makefile:

CC=g++

FFMPEG_LIBS=    libavdevice                        \
                libavformat                        \
                libavfilter                        \
                libavcodec                         \
                libswresample                      \
                libswscale                         \
                libavutil                          \

CPPFLAGS := -Wall -g $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CPPFLAGS)
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) -lm $(LDLIBS)

SOURCES=        muxing                             \

OBJS=$(addsuffix .o,$(SOURCES))

all: $(OBJS) $(SOURCES)

我得到了一堆这样的错误:

$ g++   muxing.o  -L/usr/local/Cellar/ffmpeg/3.2.4/lib -lavdevice -lavformat -lavfilter -lavcodec -lswresample -lswscale -lavutil  -lm -o muxing
Undefined symbols for architecture x86_64:
  "av_dict_set(AVDictionary**, char const*, char const*, int)", referenced from:
      _main in muxing.o
  "av_strerror(int, char*, unsigned long)", referenced from:
      av_make_error_string(char*, unsigned long, int) in muxing.o
  "avio_closep(AVIOContext**)", referenced from:
      _main in muxing.o
  "swr_convert(SwrContext*, unsigned char**, int, unsigned char const**, int)", referenced from:
      write_audio_frame(AVFormatContext*, OutputStream*) in muxing.o
  "av_dict_copy(AVDictionary**, AVDictionary const*, int)", referenced from:
      open_video(AVFormatContext*, AVCodec*, OutputStream*, AVDictionary*) in muxing.o
      open_audio(AVFormatContext*, AVCodec*, OutputStream*, AVDictionary*) in muxing.o
  "av_dict_free(AVDictionary**)", referenced from:
      open_video(AVFormatContext*, AVCodec*, OutputStream*, AVDictionary*) in muxing.o
      open_audio(AVFormatContext*, AVCodec*, OutputStream*, AVDictionary*) in muxing.o
  "av_rescale_q(long long, AVRational, AVRational)", referenced from:
      write_audio_frame(AVFormatContext*, OutputStream*) in muxing.o
  "av_compare_ts(long long, AVRational, long long, AVRational)", referenced from:
      _main in muxing.o
      get_video_frame(OutputStream*) in muxing.o
      get_audio_frame(OutputStream*) in muxing.o

这是否意味着那些libs还没有准备好使用x64?我强烈需要将该代码(muxing.c)与我的C ++代码混合使用,因为我必须使用ImageMagick(我的代码是用C ++编写的)动态渲染视频。

在这种情况下如何混合使用C ++和C?

我的环境是:OS X 10.12.3

0 个答案:

没有答案