0
votes

I have configured Webports, ffmpeg; and I have created the following Makefile for the current project. However, I have met some problem with ffmpeg library linking.

$ 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

Can you tell me what I am doing wrong here, my Makefile is shown below:

VALID_TOOLCHAINS := pnacl glibc clang-newlib win

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

TARGET = client

OTHERDIR=src

INC_DIR = inc

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

INCLUDES = -I$(INC_DIR) -I$(FFMPEG_INC_DIR)

include $(NACL_SDK_ROOT)/tools/common.mk

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

LIBS = nacl_io ppapi_cpp ppapi

CFLAGS = -Wall -g -O2 $(INCLUDES) -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

SOURCES = $(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

# Build rules generated by macros from common.mk:

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

# The PNaCl workflow uses both an unstripped and finalized/stripped binary. # On NaCl, only produce a stripped binary for Release configs (not Debug). 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),))

And here is the way, how the library has been used in the class context.

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();
  }
...
1

1 Answers

0
votes

I have solved this problem by adding linking with additional libraries for FFMPEG: vpx, vorbis, lame. And it is very important to keep the order of linked libraries.

.....
...
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))))
....
...