gpt4 book ai didi

c - make 使用 autotools 给出 undefined reference 错误,而自定义 Makefile 工作正常

转载 作者:太空宇宙 更新时间:2023-11-04 08:06:16 24 4
gpt4 key购买 nike

我正在尝试将 ccextractor(开源隐藏式字幕提取器)的构建机制从自定义 Makefile 转换为 Autotools 生成的 Makefile。

当前的 Makefile 如下所示:

SHELL = /bin/sh

CC = gcc
SYS := $(shell gcc -dumpmachine)
CFLAGS = -O3 -std=gnu99 -s
INCLUDE = -Isrc/gpacmp4/ -Isrc/libpng -Isrc/lib_hash -Isrc/protobuf-c -Isrc/zlib -Isrc/lib_ccx -Isrc/.
INCLUDE += -Isrc/zvbi -Isrc/utf8proc
ALL_FLAGS = -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT
LDFLAGS = -lm

ifneq (, $(findstring linux, $(SYS)))
CFLAGS +=-DGPAC_CONFIG_LINUX
endif
TARGET = ccextractor

OBJS_DIR = objs
VPATH = src:src/gpacmp4:src/libpng:src/zlib:src/lib_ccx:src/zvbi:src/lib_hash:src/utf8proc:src/protobuf-c

SRCS_DIR = src
SRCS_C = $(wildcard $(SRCS_DIR)/*.c)
OBJS = $(SRCS_C:$(SRCS_DIR)/%.c=$(OBJS_DIR)/%.o)

SRCS_CCX_DIR = $(SRCS_DIR)/lib_ccx
SRCS_CCX = $(wildcard $(SRCS_CCX_DIR)/*.c)
OBJS_CCX = $(SRCS_CCX:$(SRCS_CCX_DIR)/%.c=$(OBJS_DIR)/%.o)

SRCS_PNG_DIR = $(SRCS_DIR)/libpng
SRCS_PNG = $(wildcard $(SRCS_PNG_DIR)/*.c)
OBJS_PNG = $(SRCS_PNG:$(SRCS_PNG_DIR)/%.c=$(OBJS_DIR)/%.o)

SRCS_ZVBI_DIR = $(SRCS_DIR)/zvbi
SRCS_ZVBI = $(wildcard $(SRCS_ZVBI_DIR)/*.c)
OBJS_ZVBI = $(SRCS_ZVBI:$(SRCS_ZVBI_DIR)/%.c=$(OBJS_DIR)/%.o)

SRCS_GPACMP4_DIR = $(SRCS_DIR)/gpacmp4
SRCS_GPACMP4_C = $(wildcard $(SRCS_GPACMP4_DIR)/*.c)
SRCS_GPACMP4_CPP = $(wildcard $(SRCS_GPACMP4_DIR)/*.cpp)
OBJS_GPACMP4 = $(SRCS_GPACMP4_C:$(SRCS_GPACMP4_DIR)/%.c=$(OBJS_DIR)/%.o) \
$(SRCS_GPACMP4_CPP:$(SRCS_GPACMP4_DIR)/%.cpp=$(OBJS_DIR)/%.o)

SRCS_ZLIB_DIR = $(SRCS_DIR)/zlib
SRCS_ZLIB = $(wildcard $(SRCS_ZLIB_DIR)/*.c)
OBJS_ZLIB = $(SRCS_ZLIB:$(SRCS_ZLIB_DIR)/%.c=$(OBJS_DIR)/%.o)

SRCS_HASH_DIR = $(SRCS_DIR)/lib_hash
SRCS_HASH = $(wildcard $(SRCS_HASH_DIR)/*.c)
OBJS_HASH = $(SRCS_HASH:$(SRCS_HASH_DIR)/%.c=$(OBJS_DIR)/%.o)

SRCS_UTF8_DIR = $(SRCS_DIR)/utf8proc
SRCS_UTF8 = $(SRCS_UTF8_DIR)/utf8proc.c
OBJS_UTF8 = $(SRCS_UTF8:$(SRCS_UTF8_DIR)/%.c=$(OBJS_DIR)/%.o)

INSTLALL = cp -f -p
INSTLALL_PROGRAM = $(INSTLALL)
DESTDIR = /usr/bin

ifeq ($(ENABLE_HARDSUBX),yes)
ENABLE_OCR=yes
CFLAGS+=-DENABLE_HARDSUBX
CFLAGS+= $(shell pkg-config --cflags libavcodec)
CFLAGS+= $(shell pkg-config --cflags libavformat)
CFLAGS+= $(shell pkg-config --cflags libavutil)
CFLAGS+= $(shell pkg-config --cflags libswscale)
AV_LDFLAGS+= $(shell pkg-config --libs libavcodec )
AV_LDFLAGS+= $(shell pkg-config --libs libavformat )
AV_LDFLAGS+= $(shell pkg-config --libs libavutil )
AV_LDFLAGS+= $(shell pkg-config --libs libswscale )
ifeq ($(AV_LDFLAGS),$(EMPTY))
$(error **ERROR** "libav not found")
else
$(info "libav found")
endif
LDFLAGS+= $(AV_LDFLAGS)
endif

ifeq ($(ENABLE_OCR),yes)
CFLAGS+=-DENABLE_OCR -DPNG_NO_CONFIG_H
LEPT_LDFLAGS+= $(shell pkg-config --libs lept)

ifneq ($(shell pkg-config --exists tesseract), $(EMPTY))
TESS_LDFLAGS+= $(shell pkg-config --libs tesseract)
TESS_CFLAGS+= $(shell pkg-config --cflags tesseract)
else
#fix for raspberry pi not having a pkgconfig file for tesseract
ifneq ($(wildcard /usr/include/tesseract/*),$(EMPTY))
TESS_LDFLAGS+= -ltesseract
TESS_CFLAGS+= -I/usr/include/tesseract
endif
endif

#error checking of library are there or not
ifeq ($(TESS_LDFLAGS),$(EMPTY))
$(error **ERROR** "tesseract not found")
else
#TODO print the version of library found
$(info "tesseract found")
endif

ifeq ($(LEPT_LDFLAGS),$(EMPTY))
$(error **ERROR** "leptonica not found")
else
#TODO print the version of library found
$(info "Leptonica found")
endif

CFLAGS += $(TESS_CFLAGS)
CFLAGS += $(shell pkg-config --cflags lept)
LDFLAGS += $(TESS_LDFLAGS)
LDFLAGS += $(LEPT_LDFLAGS)
endif


ifeq ($(ENABLE_FFMPEG),yes)
CFLAGS+=-DENABLE_FFMPEG
CFLAGS+= $(shell pkg-config --cflags libavcodec)
CFLAGS+= $(shell pkg-config --cflags libavformat)
CFLAGS+= $(shell pkg-config --cflags libavutil)
LDFLAGS+= $(shell pkg-config --libs libavcodec )
LDFLAGS+= $(shell pkg-config --libs libavformat )
LDFLAGS+= $(shell pkg-config --libs libavutil )
endif

.PHONY: all
all: pre-build objs_dir $(TARGET)

.PHONY: objs_dir
objs_dir:
mkdir -p $(OBJS_DIR)

$(TARGET): $(OBJS) $(OBJS_PNG) $(OBJS_GPACMP4) $(OBJS_ZVBI) $(OBJS_ZLIB) $(OBJS_HASH) $(OBJS_CCX) $(OBJS_UTF8)
$(CC) $(ALL_FLAGS) $(CFLAGS) $(OBJS) $(OBJS_CCX) $(OBJS_PNG) $(OBJS_ZVBI) $(OBJS_GPACMP4) $(OBJS_ZLIB) $(OBJS_HASH) $(OBJS_UTF8) $(LDFLAGS) -o $@

$(OBJS_DIR)/%.o: %.c
$(CC) -c $(ALL_FLAGS) $(INCLUDE) $(CFLAGS) $< -o $@

$(OBJS_DIR)/%.o: %.cpp
$(CC) -c $(ALL_FLAGS) $(INCLUDE) $(CFLAGS) $< -o $@ -Isrc/gpacmp4

$(OBJS_DIR)/ccextractor.o: ccextractor.c
$(CC) -c $(ALL_FLAGS) $(INCLUDE) $(CFLAGS) -O0 $< -o $@

.PHONY: clean
clean:
rm -rf $(TARGET) 2>/dev/null || true
rm -rf $(OBJS_CCX) $(OBJS_PNG) $(OBJS_ZLIB) $(OBJS_GPACMP4) $(OBJS_HASH) $(OBJS_UTF8) $(OBJS) 2>/dev/null || true
rm -rdf $(OBJS_DIR) 2>/dev/null || true
rm -rf .depend 2>/dev/null || true

.PHONY: install
install: $(TARGET)
$(INSTLALL_PROGRAM) $(TARGET) $(DESTDIR)

.PHONY: uninstall
uninstall:
rm -iv $(DESTDIR)/$(TARGET)

.PHONY: depend dep
depend dep:
$(CC) $(CFLAGS) $(INCLUDE) -E -MM $(SRCS_C) $(SRCS_PNG) $(SRCS_ZVBI) $(SRCS_ZLIB) $(SRCS_HASH) $(SRCS_UTF8) $(SRCS_CCX) \
$(SRCS_GPACMP4_C) $(SRCS_GPACMP4_CPP) |\
sed 's/^[a-zA-Z_0-9]*.o/$(OBJS_DIR)\/&/' > .depend

.PHONY: pre-build
pre-build:
./pre-build.sh

-include .depend

通过上面的 Makefile 构建工作正常。我的 Makefile.am 看起来像这样:

bin_PROGRAMS = ccextractor
ccextractor_SOURCES = \
**Removing common content of Makefile.am as below due to maximum character limit**

AM_CPPFLAGS = -I src -I /usr/include/leptonica/ -I /usr/include/tesseract/ -I src/lib_ccx/ -I src/gpacmp4/ -I src/libpng/ -I src/zlib/ -I src/zvbi/ -I src/lib_hash/ -I src/protobuf-c/ -I src/utf8proc/

AM_CFLAGS = -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR

AM_LDFLAGS = -lm -lz -ltesseract -llept

如果我运行 makeautoreconf -i 之后在上面的文件中,构建失败并出现错误:

/usr/bin/ld: src/gpacmp4/av_parsers.o: undefined reference to symbol 'trunc@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line

如果我运行 ./configure作为./configure LIBS="-lm -lz"构建失败,错误如下:

/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/gpacmp4/drm_sample.c:1358: undefined reference to `gf_isom_get_track_from_file'
src/gpacmp4/drm_sample.o: In function `gf_isom_get_adobe_protection_info':
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/gpacmp4/drm_sample.c:1378: undefined reference to `gf_isom_get_track_from_file'
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/gpacmp4/drm_sample.c:1387: undefined reference to `IsMP4Description'
src/gpacmp4/drm_sample.o: In function `gf_isom_cenc_is_pattern_mode':
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/gpacmp4/drm_sample.c:1401: undefined reference to `gf_isom_get_track_from_file'
src/gpacmp4/drm_sample.o: In function `gf_isom_ipmpx_remove_tool_list':
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/gpacmp4/drm_sample.c:1421: undefined reference to `gf_odf_desc_del'
collect2: error: ld returned 1 exit status

treesrc目录是:

.
├── ccextractor.c
├── CCExtractorConfig.h.in
├── ccextractor.o
├── CMakeLists.txt
├── gpacmp4
│   ├── avc_ext.c
│   ├── avc_ext.o
│   ├── avilib.c
│   ├── avilib.o
│   ├── av_parsers.c
│   ├── drm_sample.o
│   ├── error.c
│   ├── error.o
│   ├── gpac
│   │   ├── avparse.h
│   │   ├── base_coding.h
│   │   ├── bitstream.h
│   │   ├── config_file.h
│   │   ├── configuration.h
│   │   ├── constants.h
│   │   ├── events_constants.h
│   │   ├── ietf.h
│   │   ├── internal
│   │   │   ├── avilib.h
│   │   │   ├── isomedia_dev.h
│   │   │   ├── media_dev.h
│   │   │   ├── odf_dev.h
│   │   │   ├── odf_parse_common.h
│   │   │   └── ogg.h
│   │   ├── isomedia.h
│   │   ├── list.h
│   │   ├── math.h
│   │   ├── media_tools.h
│   │   ├── mpeg4_odf.h
│   │   ├── network.h
│   │   ├── revision.h
│   │   ├── setup.h
│   │   ├── sync_layer.h
│   │   ├── tools.h
│   │   ├── utf.h
│   │   └── version.h
│   ├── gpac_ogg.c
│   ├── hinting.c
│   ├── ipmpx_code.c
│   ├── ipmpx_parse.c
│   ├── isom_intern.c
│   ├── isom_read.c
│   ├── isom_store.c
│   ├── isom_write.c
│   ├── list.c
│   ├── math.c
│   ├── media.c
│   ├── media_odf.c
│   ├── meta.c
│   ├── movie_fragments.c
│   ├── mp4.c
│   ├── odf_code.c
│   ├── odf_codec.c
│   ├── odf_command.c
│   ├── os_config_init.c
│   ├── os_divers.c
│   ├── os_file.c
│   ├── qos.c
│   ├── ReadMe.txt
│   ├── sample_descs.c
│   ├── slc.c
│   ├── stbl_read.c
│   ├── stbl_write.c
│   ├── track.c
│   ├── tx3g.c
│   ├── url.c
│   └── utf.c
├── lib_ccx
│   ├── activity.c
│   ├── activity.h
│   ├── asf_constants.h
│   ├── asf_functions.c
│   ├── avc_functions.c
│   ├── avc_functions.h
│   ├── bitstream.h
│   ├── cc_bitstream.c
│   ├── ccfont2.xbm
│   ├── ccx_common_char_encoding.c
│   ├── ccx_common_char_encoding.h
│   ├── ccx_decoders_708.h
│   ├── ccx_decoders_708_output.c
│   ├── ccx_encoders_xds.h
│   ├── ccx_gxf.c
│   ├── ccx_gxf.h
│   ├── ccx_mp4.h
│   ├── dvd_subtitle_decoder.c
│   ├── utility.h
│   ├── wtv_constants.h
│   └── wtv_functions.c
├── lib_hash
│   ├── README
│   ├── sha2.c
│   └── sha2.h
├── libpng
│   ├── png.c
│   ├── pngconf.h
│   ├── pngdebug.h
│   ├── pngerror.c
│   ├── pngget.c
| |
├── protobuf-c
│   ├── protobuf-c.c
│   └── protobuf-c.h
├── utf8proc
│   ├── utf8proc.c
│   ├── utf8proc_data.c
│   └── utf8proc.h
├── win_iconv
│   ├── iconv.h
│   └── win_iconv.c
├── win_spec_incld
│   ├── dirent.h
│   ├── inttypes.h
│   └── stdint.h
├── zlib
│   ├── adler32.c
│   ├── compress.c
│   ├── crc32.c
│   ├── crc32.h
│   ├── deflate.c
│   ├── deflate.h
│   ├── gzclose.c
│   ├── gzguts.h
│   ├── zutil.c
│   └── zutil.h
└── zvbi
├── bcd.h
├── bit_slicer.c
├── bit_slicer.h
├── decoder.c
├── macros.h
├── misc.h
├── raw_decoder.c
├── raw_decoder.h
├── sampling_par.c
├── sampling_par.h
├── sliced.h
└── zvbi_decoder.h
**Stripped some filenames (not directory) due to max character limit**

此外,所有包含都是在 src 的子目录中以完整路径完成的,例如 gpacmp4 中的文件目录,#include <gpac/avparse.h> .除了主要的 ccextractor.c文件,其中所有 -I flags提供。

引用ccextractor原代码: https://github.com/CCExtractor/ccextractor

原文Makefile将在linux目录。

PS:目前我正在尝试让ccextractor构建所有的检查,稍后会介绍。对于简化机制ccextractor/linux/build有引用值(value)。

即使是最微小的帮助,我们也会感激。

更新:(由@MadScientist 提供)我更新了 Makefile.am作为:

AUTOMAKE_OPTIONS = foreign

bin_PROGRAMS = ccextractor
ccextractor_SOURCES = \
src/ccextractor.c \
src/gpacmp4/avc_ext.c \
src/gpacmp4/avilib.c \
src/gpacmp4/av_parsers.c \
src/gpacmp4/base_encoding.c \
src/gpacmp4/bitstream.c \
src/gpacmp4/box_code_3gpp.c \
src/gpacmp4/box_code_adobe.c \
src/gpacmp4/box_code_apple.c \
src/gpacmp4/box_code_base.c \
src/gpacmp4/box_code_drm.c \
src/gpacmp4/box_code_meta.c \
src/gpacmp4/box_funcs.c \
src/gpacmp4/configfile.c \
src/gpacmp4/data_map.c \
src/gpacmp4/desc_private.c \
src/gpacmp4/descriptors.c \
src/gpacmp4/drm_sample.c \
src/gpacmp4/error.c \
src/gpacmp4/gpac/avparse.h \
src/gpacmp4/gpac/base_coding.h \
src/gpacmp4/gpac/bitstream.h \
src/gpacmp4/gpac/config_file.h \
src/gpacmp4/gpac/configuration.h \
src/gpacmp4/gpac/constants.h \
src/gpacmp4/gpac/events_constants.h \
src/gpacmp4/gpac/ietf.h \
src/gpacmp4/gpac/internal
src/gpacmp4/gpac/internal/avilib.h \
src/gpacmp4/gpac/internal/isomedia_dev.h \
src/gpacmp4/gpac/internal/media_dev.h \
src/gpacmp4/gpac/internal/odf_dev.h \
src/gpacmp4/gpac/internal/odf_parse_common.h \
src/gpacmp4/gpac/internal/ogg.h \
src/gpacmp4/gpac/isomedia.h \
src/gpacmp4/gpac/list.h \
src/gpacmp4/gpac/math.h \
src/gpacmp4/gpac/media_tools.h \
src/gpacmp4/gpac/mpeg4_odf.h \
src/gpacmp4/gpac/network.h \
src/gpacmp4/gpac/revision.h \
src/gpacmp4/gpac/setup.h \
src/gpacmp4/gpac/sync_layer.h \
src/gpacmp4/gpac/tools.h \
src/gpacmp4/gpac/utf.h \
src/gpacmp4/gpac/version.h \
src/gpacmp4/gpac_ogg.c \
src/gpacmp4/hinting.c \
src/gpacmp4/ipmpx_code.c \
src/gpacmp4/ipmpx_parse.c \
src/gpacmp4/isom_intern.c \
src/gpacmp4/isom_read.c \
src/gpacmp4/isom_store.c \
src/gpacmp4/isom_write.c \
src/gpacmp4/list.c \
src/gpacmp4/math.c \
src/gpacmp4/media.c \
src/gpacmp4/media_odf.c \
src/gpacmp4/meta.c \
src/gpacmp4/movie_fragments.c \
src/gpacmp4/mp4.c \
src/gpacmp4/odf_code.c \
src/gpacmp4/odf_codec.c \
src/gpacmp4/odf_command.c \
src/gpacmp4/os_config_init.c \
src/gpacmp4/os_divers.c \
src/gpacmp4/os_file.c \
src/gpacmp4/qos.c \
src/gpacmp4/ReadMe.txt
src/gpacmp4/sample_descs.c \
src/gpacmp4/slc.c \
src/gpacmp4/stbl_read.c \
src/gpacmp4/stbl_write.c \
src/gpacmp4/track.c \
src/gpacmp4/tx3g.c \
src/gpacmp4/url.c \
src/gpacmp4/utf.c \
src/lib_ccx/activity.c \
src/lib_ccx/activity.h \
src/lib_ccx/asf_constants.h \
src/lib_ccx/asf_functions.c \
src/lib_ccx/avc_functions.c \
src/lib_ccx/avc_functions.h \
src/lib_ccx/bitstream.h \
src/lib_ccx/cc_bitstream.c \
src/lib_ccx/ccx_common_char_encoding.c \
src/lib_ccx/ccx_common_char_encoding.h \
src/lib_ccx/ccx_common_common.c \
src/lib_ccx/ccx_common_common.h \
src/lib_ccx/ccx_common_constants.c \
src/lib_ccx/ccx_common_constants.h \
src/lib_ccx/ccx_common_option.c \
src/lib_ccx/ccx_common_option.h \
src/lib_ccx/ccx_common_platform.h \
src/lib_ccx/ccx_common_structs.h \
src/lib_ccx/ccx_common_timing.c \
src/lib_ccx/ccx_common_timing.h \
src/lib_ccx/ccx_decoders_608.c \
src/lib_ccx/ccx_decoders_608.h \
src/lib_ccx/ccx_decoders_708.c \
src/lib_ccx/ccx_decoders_708_encoding.c \
src/lib_ccx/ccx_decoders_708_encoding.h \
src/lib_ccx/ccx_decoders_708.h \
src/lib_ccx/ccx_decoders_708_output.c \
src/lib_ccx/ccx_decoders_708_output.h \
src/lib_ccx/ccx_decoders_common.c \
src/lib_ccx/ccx_decoders_common.h \
src/lib_ccx/ccx_decoders_isdb.c \
src/lib_ccx/ccx_decoders_isdb.h \
src/lib_ccx/ccx_decoders_structs.h \
src/lib_ccx/ccx_decoders_vbi.c \
src/lib_ccx/ccx_decoders_vbi.h \
src/lib_ccx/ccx_decoders_xds.c \
src/lib_ccx/ccx_decoders_xds.h \
src/lib_ccx/ccx_demuxer.c \
src/lib_ccx/ccx_demuxer.h \
src/lib_ccx/ccx_dtvcc.c \
src/lib_ccx/ccx_dtvcc.h \
src/lib_ccx/ccx_encoders_common.c \
src/lib_ccx/ccx_encoders_common.h \
src/lib_ccx/ccx_encoders_curl.c \
src/lib_ccx/ccx_encoders_g608.c \
src/lib_ccx/ccx_encoders_helpers.c \
src/lib_ccx/ccx_encoders_helpers.h \
src/lib_ccx/ccx_encoders_sami.c \
src/lib_ccx/ccx_encoders_smptett.c \
src/lib_ccx/ccx_encoders_splitbysentence.c \
src/lib_ccx/ccx_encoders_spupng.c \
src/lib_ccx/ccx_encoders_spupng.h \
src/lib_ccx/ccx_encoders_srt.c \
src/lib_ccx/ccx_encoders_ssa.c \
src/lib_ccx/ccx_encoders_structs.h \
src/lib_ccx/ccx_encoders_transcript.c \
src/lib_ccx/ccx_encoders_webvtt.c \
src/lib_ccx/ccx_encoders_xds.c \
src/lib_ccx/ccx_encoders_xds.h \
src/lib_ccx/ccx_gxf.c \
src/lib_ccx/ccx_gxf.h \
src/lib_ccx/ccx_mp4.h \
src/lib_ccx/ccx_share.c \
src/lib_ccx/ccx_share.h \
src/lib_ccx/ccx_sub_entry_message.pb-c.c \
src/lib_ccx/ccx_sub_entry_message.pb-c.h \
src/lib_ccx/CMakeLists.txt
src/lib_ccx/compile_info.h \
src/lib_ccx/compile_info_real.h \
src/lib_ccx/configuration.c \
src/lib_ccx/configuration.h \
src/lib_ccx/disable_warnings.h \
src/lib_ccx/dvb_subtitle_decoder.c \
src/lib_ccx/dvb_subtitle_decoder.h \
src/lib_ccx/dvd_subtitle_decoder.c \
src/lib_ccx/dvd_subtitle_decoder.h \
src/lib_ccx/es_functions.c \
src/lib_ccx/es_userdata.c \
src/lib_ccx/ffmpeg_intgr.c \
src/lib_ccx/ffmpeg_intgr.h \
src/lib_ccx/file_buffer.h \
src/lib_ccx/file_functions.c \
src/lib_ccx/general_loop.c \
src/lib_ccx/hamming.h \
src/lib_ccx/hardsubx.c \
src/lib_ccx/hardsubx_classifier.c \
src/lib_ccx/hardsubx_decoder.c \
src/lib_ccx/hardsubx.h \
src/lib_ccx/hardsubx_imgops.c \
src/lib_ccx/hardsubx_utility.c \
src/lib_ccx/lib_ccx.c \
src/lib_ccx/lib_ccx.h \
src/lib_ccx/list.h \
src/lib_ccx/matroska.c \
src/lib_ccx/matroska.h \
src/lib_ccx/myth.c \
src/lib_ccx/networking.c \
src/lib_ccx/networking.h \
src/lib_ccx/ocr.c \
src/lib_ccx/ocr.h \
src/lib_ccx/output.c \
src/lib_ccx/params.c \
src/lib_ccx/params_dump.c \
src/lib_ccx/sequencing.c \
src/lib_ccx/spupng_encoder.c \
src/lib_ccx/spupng_encoder.h \
src/lib_ccx/stdintmsc.h \
src/lib_ccx/stream_functions.c \
src/lib_ccx/teletext.h \
src/lib_ccx/telxcc.c \
src/lib_ccx/ts_functions.c \
src/lib_ccx/ts_functions.h \
src/lib_ccx/ts_info.c \
src/lib_ccx/ts_tables.c \
src/lib_ccx/ts_tables_epg.c \
src/lib_ccx/utility.c \
src/lib_ccx/utility.h \
src/lib_ccx/wtv_constants.h \
src/lib_ccx/wtv_functions.c \
src/lib_hash/sha2.c \
src/lib_hash/sha2.h \
src/libpng/png.c \
src/libpng/pngconf.h \
src/libpng/pngdebug.h \
src/libpng/pngerror.c \
src/libpng/pngget.c \
src/libpng/png.h \
src/libpng/pnginfo.h \
src/libpng/pnglibconf.h \
src/libpng/pngmem.c \
src/libpng/pngpread.c \
src/libpng/pngpriv.h \
src/libpng/pngread.c \
src/libpng/pngrio.c \
src/libpng/pngrtran.c \
src/libpng/pngrutil.c \
src/libpng/pngset.c \
src/libpng/pngstruct.h \
src/libpng/pngtrans.c \
src/libpng/pngwio.c \
src/libpng/pngwrite.c \
src/libpng/pngwtran.c \
src/libpng/pngwutil.c \
src/protobuf-c/protobuf-c.c \
src/protobuf-c/protobuf-c.h \
src/utf8proc/utf8proc.c \
src/utf8proc/utf8proc_data.c \
src/utf8proc/utf8proc.h \
src/win_iconv/iconv.h \
src/win_iconv/win_iconv.c \
src/win_spec_incld/dirent.h \
src/win_spec_incld/inttypes.h \
src/win_spec_incld/stdint.h \
src/zlib/adler32.c \
src/zlib/compress.c \
src/zlib/crc32.c \
src/zlib/crc32.h \
src/zlib/deflate.c \
src/zlib/deflate.h \
src/zlib/gzclose.c \
src/zlib/gzguts.h \
src/zlib/gzlib.c \
src/zlib/gzread.c \
src/zlib/gzwrite.c \
src/zlib/infback.c \
src/zlib/inffast.c \
src/zlib/inffast.h \
src/zlib/inffixed.h \
src/zlib/inflate.c \
src/zlib/inflate.h \
src/zlib/inftrees.c \
src/zlib/inftrees.h \
src/zlib/trees.c \
src/zlib/trees.h \
src/zlib/uncompr.c \
src/zlib/zconf.h \
src/zlib/zlib.h \
src/zlib/zutil.c \
src/zlib/zutil.h \
src/zvbi/bcd.h \
src/zvbi/bit_slicer.c \
src/zvbi/bit_slicer.h \
src/zvbi/decoder.c \
src/zvbi/macros.h \
src/zvbi/misc.h \
src/zvbi/raw_decoder.c \
src/zvbi/raw_decoder.h \
src/zvbi/sampling_par.c \
src/zvbi/sampling_par.h \
src/zvbi/sliced.h \
src/zvbi/zvbi_decoder.h

ccextractor_CFLAGS =-std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR

ccextractor_CPPFLAGS =-I /usr/include/leptonica/ -I /usr/include/tesseract/ -I src/lib_ccx/ -I src/gpacmp4/ -I src/libpng/ -I src/zlib/ -I src/zvbi/ -I src/lib_hash/ -I src/protobuf-c/ -I src/utf8proc/

ccextractor_LDADD =-lm -ltesseract -llept

ccextractor_LDFLAGS=-zmuldefs

build完美构建“ccextractor”的脚本是:

#!/bin/bash
BLD_FLAGS="-std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR"
BLD_INCLUDE="-Isrc -I /usr/include/leptonica/ -I /usr/include/tesseract/ -Isrc/lib_ccx/ -Isrc/gpacmp4/ -Isrc/libpng/ -Isrc/zlib/ -Isrc/zvbi -Isrc/lib_hash -Isrc/protobuf-c -Isrc/utf8proc"
SRC_LIBPNG="$(find src/libpng/ -name '*.c')"
SRC_ZLIB="$(find src/zlib/ -name '*.c')"
SRC_ZVBI="$(find src/zvbi/ -name '*.c')"
SRC_CCX="$(find src/lib_ccx/ -name '*.c')"
SRC_GPAC="$(find src/gpacmp4/ -name '*.c')"
SRC_HASH="$(find src/lib_hash/ -name '*.c')"
SRC_PROTOBUF="$(find src/protobuf-c/ -name '*.c')"
SRC_UTF8PROC="src/utf8proc/utf8proc.c"
BLD_SOURCES="src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_ZVBI $SRC_LIBPNG $SRC_HASH $SRC_PROTOBUF $SRC_UTF8PROC"
BLD_LINKER="-lm -zmuldefs -l tesseract -l lept"


**Stripped a call for a script which checks the git commit (nothing that'd interfere with build**

out=$((LC_ALL=C gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER) 2>&1)
res=$?
if [[ $out == *"gcc: command not found"* ]]
then
echo "Error: please install gcc";
exit 1
fi
if [[ $out == *"curl.h: No such file or directory"* ]]
then
echo "Error: please install curl development library (libcurl4-gnutls-dev for Debian/Ubuntu)";
exit 2
fi
if [[ $out == *"capi.h: No such file or directory"* ]]
then
echo "Error: please install tesseract development library (tesseract-ocr-dev for Debian/Ubuntu)";
exit 3
fi
if [[ $out == *"allheaders.h: No such file or directory"* ]]
then
echo "Error: please install leptonica development library (libleptonica-dev for Debian/Ubuntu)";
exit 4
fi
if [[ $res -ne 0 ]] # Unknown error
then
echo "Compiled with errors"
>&2 echo "$out"
exit 5
fi
echo "Compilation successful";

这里有一些初始声明 make调用:

gcc -DHAVE_CONFIG_H -I.  -I /usr/include/leptonica/ -I /usr/include/tesseract/ -I src/lib_ccx/ -I src/gpacmp4/ -I src/libpng/ -I src/zlib/ -I src/zvbi/ -I src/lib_hash/ -I src/protobuf-c/ -I src/utf8proc/  -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -g -O2 -MT src/ccextractor-ccextractor.o -MD -MP -MF src/.deps/ccextractor-ccextractor.Tpo -c -o src/ccextractor-ccextractor.o `test -f 'src/ccextractor.c' || echo './'`src/ccextractor.c
mv -f src/.deps/ccextractor-ccextractor.Tpo src/.deps/ccextractor-ccextractor.Po
gcc -DHAVE_CONFIG_H -I. -I /usr/include/leptonica/ -I /usr/include/tesseract/ -I src/lib_ccx/ -I src/gpacmp4/ -I src/libpng/ -I src/zlib/ -I src/zvbi/ -I src/lib_hash/ -I src/protobuf-c/ -I src/utf8proc/ -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -g -O2 -MT src/gpacmp4/ccextractor-avc_ext.o -MD -MP -MF src/gpacmp4/.deps/ccextractor-avc_ext.Tpo -c -o src/gpacmp4/ccextractor-avc_ext.o `test -f 'src/gpacmp4/avc_ext.c' || echo './'`src/gpacmp4/avc_ext.c
mv -f src/gpacmp4/.deps/ccextractor-avc_ext.Tpo src/gpacmp4/.deps/ccextractor-avc_ext.Po
gcc -DHAVE_CONFIG_H -I. -I /usr/include/leptonica/ -I /usr/include/tesseract/ -I src/lib_ccx/ -I src/gpacmp4/ -I src/libpng/ -I src/zlib/ -I src/zvbi/ -I src/lib_hash/ -I src/protobuf-c/ -I src/utf8proc/ -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -g -O2 -MT src/gpacmp4/ccextractor-avilib.o -MD -MP -MF src/gpacmp4/.deps/ccextractor-avilib.Tpo -c -o src/gpacmp4/ccextractor-avilib.o `test -f 'src/gpacmp4/avilib.c' || echo './'`src/gpacmp4/avilib.c
mv -f src/gpacmp4/.deps/ccextractor-avilib.Tpo src/gpacmp4/.deps/ccextractor-avilib.Po

声明make在显示 undefined reference 错误之前调用:

gcc -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -g -O2 -zmuldefs  -o ccextractor src/ccextractor-ccextractor.o src/gpacmp4/ccextractor-avc_ext.o src/gpacmp4/ccextractor-avilib.o src/gpacmp4/ccextractor-av_parsers.o src/gpacmp4/ccextractor-base_encoding.o src/gpacmp4/ccextractor-bitstream.o src/gpacmp4/ccextractor-box_code_3gpp.o src/gpacmp4/ccextractor-box_code_adobe.o src/gpacmp4/ccextractor-box_code_apple.o src/gpacmp4/ccextractor-box_code_base.o src/gpacmp4/ccextractor-box_code_drm.o src/gpacmp4/ccextractor-box_code_meta.o src/gpacmp4/ccextractor-box_funcs.o src/gpacmp4/ccextractor-configfile.o src/gpacmp4/ccextractor-data_map.o src/gpacmp4/ccextractor-desc_private.o src/gpacmp4/ccextractor-descriptors.o src/gpacmp4/ccextractor-drm_sample.o src/gpacmp4/ccextractor-error.o -lm -ltesseract -llept

/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:32: undefined reference to `mprint'
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:33: undefined reference to `change_filename_requested'
src/ccextractor-ccextractor.o: In function `sigint_handler':
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:47: undefined reference to `print_file_report'
src/ccextractor-ccextractor.o: In function `print_end_msg':
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:55: undefined reference to `mprint'
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:56: undefined reference to `mprint'
src/ccextractor-ccextractor.o: In function `main':
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:68: undefined reference to `init_options'
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:70: undefined reference to `parse_configuration'
/media/mayank/Mayank/GSOC 2017/Projects/ccextractor/src/ccextractor.c:71: undefined reference to `parse_parameters'

PS:抱歉更新延迟。感谢任何帮助。我尝试了很多事情,包括更改 #include <path/to/header> 的路径代码中的语句,然后添加 -I CFLAGS 中的声明但这也无济于事。几乎所有 undefined reference 错误都来自位于源目录子目录中的 header 中声明的函数,如 src/dir/subdir -I标志仅添加到 src/dir/然后是 src/dir/ 中的文件有类似 #include<subdir/filename.h> 的陈述.

PPS:我使用了 grep -r "<Name_of_function_leading_to_error>" .src找出声明标题。

最佳答案

您不显示调用的 make 行以链接您的代码,这将非常有用。

但是,您不想将库放入LDLFLAGS(或AM_LDLFAGS)变量;该变量用于链接器标志,如 -L 等。您应该使用 LDADD:

LDADD = -lm -lz -ltesseract -llept

如果您查看 make 正在生成的链接行,您会看到所有这些选项都出现在链接行上的任何目标文件之前;那是不对的。 GNU binutils ld 是单 channel 链接器,这意味着 -l 标志的顺序对于正确链接非常重要。

关于c - make 使用 autotools 给出 undefined reference 错误,而自定义 Makefile 工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42680874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com