添加新库以编译任何术语.如何编辑生成文件
Add new libraries to compile anyterm. How to edit Makefile?
我正在修改 Anyterm (http://anyterm.org/) 以添加我在所做的一些更改中需要的配置文件。
我正在使用 inih 项目 (https://github.com/benhoyt/inih) 来读取该文件。此文件包含我的数据库数据以连接到它。此外,我还包括mysql库,并且在编译时一切都可以。
当我尝试将新的 inih 库添加到 Makefile 时,问题就来了。Inih的文件具有扩展名.c和.cpp,但是任何术语的文件具有扩展名.cc
生成文件是这样的:
default_target: anytermd
SRC_DIR=../src
VPATH=${SRC_DIR} .
UNAME_S=$(shell uname -s)
ifeq (${UNAME_S},Darwin)
else
HAVE_GNU_LD=1
endif
LIBPBE_DIR=../libpbe
CPP_FLAGS=
GCC_FLAGS=-pthread
#GCC_FLAGS=-D_REENTRANT
COMPILE_FLAGS=$(CPP_FLAGS) $(GCC_FLAGS) -W -Wall ${OPTIMISE_FLAGS} ${DEBUG_FLAGS}
CC_COMPILE_FLAGS=$(COMPILE_FLAGS)
LINK_FLAGS=${GCC_FLAGS} ${DEBUG_FLAGS}
-lutil
ifeq (${UNAME_S},OpenBSD)
LINK_FLAGS+=-liconv
endif
ifeq (${UNAME_S},Darwin)
LINK_FLAGS+=-liconv
endif
LIBPBE_MAKE_OPTIONS=
include ../libpbe.mk
CC_SRCS=$(sort $(notdir $(wildcard ${SRC_DIR}/*.cc)) static_content.cc)
BLOBFILES=anyterm.html anyterm.js anyterm.css copy.png paste.png copy.gif paste.gif
BLOBS=$(addsuffix .blob.o,$(BLOBFILES))
OBJS=$(addsuffix .o,$(notdir $(basename $(CC_SRCS))))
%.o: %.cc
$(CXX) $(CC_COMPILE_FLAGS) -c $<
ifdef HAVE_GNU_LD
%.blob.o: ../browser/%
cp $^ . ; $(LD) -r -b binary -o $@ $* ; rm $*
else
%.blob.c: ../browser/% ./mk_blob
./mk_blob $(subst .,_,$*) < $< > $@
mk_blob: mk_blob.c
$(CC) -o $@ $<
endif
anytermd: $(OBJS) $(BLOBS) $(LIBPBE_LIB)
$(CXX) -o $@ -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX $(OBJS) -rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto $(BLOBS) $(LINK_FLAGS)
%.d: %.cc
$(CXX) -MM -MG -MT $@ -MT $(<:%.cc=%.o) $(CPP_FLAGS) $(GCC_FLAGS) -o $@ $<
DEPENDS=$(addsuffix .d,$(basename $(OBJS)))
-include $(DEPENDS)
install: FORCE
install anytermd /usr/local/bin
clean: FORCE
$(RM) -f *.o *.blob.c static_content.cc
veryclean: clean
$(RM) *.d
.PHONY: default_target install FORCE
static_content.cc: ../scripts/mk_static_content.sh ../browser/*
PATH="$${PATH}:../scripts" ../scripts/mk_static_content.sh $(BLOBFILES) > $@
static_content.o: CPP_FLAGS+=-I../src
inih 的文件在 src 目录中,当我尝试执行"make"时,我收到以下错误:
Anyterm.o: In function `checkPermission(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, booking_info&)':
Anyterm.cc:(.text+0x4527): undefined reference to `INIReader::INIReader(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
Anyterm.cc:(.text+0x4596): undefined reference to `INIReader::ParseError() const'
Anyterm.cc:(.text+0x46a7): undefined reference to `INIReader::Get(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
Anyterm.cc:(.text+0x4894): undefined reference to `INIReader::Get(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
Anyterm.cc:(.text+0x49e2): undefined reference to `INIReader::Get(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
Anyterm.cc:(.text+0x4af5): undefined reference to `INIReader::Get(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const'
这让我相信 inih 的库在链接器中缺失。我必须在 Makefile 中更改什么才能使用 inh 编译任何术语?
非常感谢。
我已经对Makefile进行了这些更改,并且对我有用:
CPP_FLAGS=-I$(SRC_DIR)
...
FILTER=mk_blob.c
CC_SRCS=$(sort $(notdir $(wildcard ${SRC_DIR}/*.cc)) static_content.cc)
CC_SRCS+=$(sort $(filter-out ${FILTER},$(notdir $(wildcard ${SRC_DIR}/*.c))))
CC_SRCS+=$(sort $(notdir $(wildcard ${SRC_DIR}/*.cpp)))
...
%.o: %.c
$(CXX) $(CC_COMPILE_FLAGS) -c $<
%.o: %.cpp
$(CXX) $(CC_COMPILE_FLAGS) -c $<
感谢大家的帮助。
相关文章:
- 编辑文件中的文本
- UE4 - Visual Studio在我从编辑器添加新的c ++文件后无法打开任何源文件 - UBT_COMPILED
- 在编辑头文件时,VS Intellisense如何从stdafx.h中查找定义
- 读取目录中的多个文件以进行编辑和写入另一组文件
- 如何使用 c++ 实现并发文件/文本编辑?
- 当有 icqdesktop 错误时如何编辑制作文件 (制作: *** [所有] 错误 2) Ubuntu 18.04 6
- 在 Visual Studios 中关闭 rc 资源文件的编辑
- C++/RapidXML:编辑节点并写入新的 XML 文件没有更新的节点
- 在结构函数之间传递文件路径 C++ 编辑:修复LNK2019错误
- 如何限制文件大小,以便我的程序在变大之后创建一个新文件?并编辑新创建的文件的名称
- 如何编辑二进制文件中的特定值
- 从数据集 Blob 字段中打开和编辑文件
- 为什么在编辑 fastq 文件并将输出写入新的 fastq 文件时引入不可打印字符?
- 如何通过在运行时编辑文件来设置窗口属性
- 如何在不覆盖其他数据的情况下编辑文件中的数据
- MFC - 编辑文件打开操作
- 在C++中搜索和编辑文件
- 如何知道何时编辑文件
- 使用cstdio就地编辑文件
- 如何在c++中读取和编辑文件txt