0

我已经配置了Webports,ffmpeg;我为当前项目创建了以下 Makefile。但是,我在 ffmpeg 库链接方面遇到了一些问题。

$ TOOLCHAIN=pnacl make
  LINK pnacl/Release/client_unstripped.bc
pnacl/Release/src/client.o: error: undefined reference to 'av_register_all'
make: *** [pnacl/Release/client_unstripped.bc] Error 1

你能告诉我我在这里做错了什么吗,我的 Makefile 如下所示:

VALID_TOOLCHAINS := pnacl glibc clang-newlib win

NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..)

目标 = 客户

其他目录=src

INC_DIR = 公司

FFMPEG_INC_DIR = ../../toolchain/mac_pnacl/le32-nacl/usr/include

包括 = -I$(INC_DIR) -I$(FFMPEG_INC_DIR)

包括 $(NACL_SDK_ROOT)/tools/common.mk

CHROME_ARGS += --allow-nacl-socket-api=localhost

LIBS = nacl_io ppapi_cpp ppapi

CFLAGS = -Wall -g -O2 $(包括) -L../../toolchain/mac_pnacl/le32-nacl/usr/lib -lavformat \ -lvpx -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -logg -lmp3lame -lm -pthread -lavcodec -lvpx -lvorbisenc -lvorbis -logg \ -ltheoraenc -ltheoradec -logg -lmp3lame -lm -pthread -lswresample -lm -lavutil -lm -lavdevice -lavfilter

来源 = $(OTHERDIR)/tcp_util.cc $(OTHERDIR)/tpool.cc $(OTHERDIR)/net.cc $(OTHERDIR)/rtsp_response.cc \ $(OTHERDIR)/rtsp.cc $(OTHERDIR)/rtsp_common。 cc \ $(OTHERDIR)/rtsp_client.cc $(OTHERDIR)/udp_util.cc \ $(OTHERDIR)/client.cc

# 构建由 common.mk 中的宏生成的规则:

$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))

# PNaCl 工作流使用未剥离和最终/剥离的二进制文件。# 在 NaCl 上,只为发布配置(不是调试)生成一个剥离的二进制文件。ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG)))) $(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$( LIBS),$(DEPS))) $(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) else $(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$( LIBS),$(DEPS))) endif

$(eval $(call NMF_RULE,$(TARGET),))

这就是在类上下文中如何使用库的方式。

class VideoDecodePack {
public:
    VideoDecodePack() {
        av_register_all();
    }
};

class ClientInstance : public pp::Instance {
 public:
  explicit ClientInstance(PP_Instance instance) : pp::Instance(instance){
    cses = InitRtspClientSession();
    _videoDecoder = new VideoDecodePack();
  }
...
4

1 回答 1

0

我通过添加与 FFMPEG 的其他库的链接解决了这个问题:vpx、vorbis、lame。保持链接库的顺序非常重要。

.....
...
TARGET = client
INC_DIR := inc

include $(NACL_SDK_ROOT)/tools/common.mk

DEPS = ppapi_simple nacl_io
LIBS = ppapi_simple nacl_io ppapi pthread \
avformat vpx vorbisenc vorbis ogg theoraenc \
theoradec mp3lame m avcodec swresample avutil \
avdevice avfilter

OTHERDIR = src

CFLAGS = -Wall
# -I$(INC_DIR)
SOURCES = $(OTHERDIR)/client.cc

# Build rules generated by macros from common.mk:

$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
....
...   
于 2016-04-14T05:39:00.447 回答