我想创建一个 makefile 来将 freetype 库静态编译成ubuntu
. 从她的安装说明中发现
The following should work on all Unix systems where the `make'
command invokes GNU Make:
./configure [options]
make
make install (as root)
The default installation path is `/usr/local'. It can be changed
with the `--prefix=<path>' option. Example:
./configure --prefix=/usr
对此只做了一点补充:我只需要静态库,不需要动态库。因此,我用手在控制台中输入的命令如下所示:
elvin@ubuntu:~/lab1/freetype$ ./configure --prefix=/home/elvin/lab1/freetype --enable-freetype-config --enable-static --disable-shared
它没有错误地工作,并且在没有 sudo 的情况下启动。然后(根据文档)我们执行命令make
:
elvin@ubuntu:~/lab1/freetype$ make
其输出的一小部分'a:
./builds/unix/libtool --mode=compile gcc -pedantic -ansi -I/home/elvin/.local/share/Trash/files/freetype.16/objs -I./builds/unix -I/home/elvin/.local/share/Trash/files/freetype.16/include -c -Wall -g -O2 -fvisibility=hidden -I/usr/local/include -I/usr/local/include/libpng16 -I/usr/local/include -DFT_CONFIG_CONFIG_H="<ftconfig.h>" -DFT2_BUILD_LIBRARY -DFT_CONFIG_MODULES_H="<ftmodule.h>" -DFT_CONFIG_OPTIONS_H="<ftoption.h>" -o /home/elvin/.local/share/Trash/files/freetype.16/objs/ftsystem.lo builds/unix/ftsystem.c
最后(应该是 sudo):
elvin@ubuntu:~/lab1/freetype$ sudo make install
一切都组装好了,静态库出现了。
现在我正在做同样的事情,但在 makefile 的帮助下:
PathFreetype:=freetype
#to know the folder
mkfile_path2 := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir2 := $(dir $(mkfile_path2))
#makefile узнает,где он
LIB:=lib
empty:=
space:= $(empty) $(empty)
mkfile_dir2:=$(subst $(space),$(empty),$(mkfile_dir2))
mkfile_dir2:=$(mkfile_dir2)$(PathFreetype)
#удаляю пробел в конце пути к папке и дописываю freetype
# we need this to make static compile of libpng as it requiers the full absolute path to create a static lib ./configure [--prefix=/path] <---— path!
static:
echo "$(mkfile_dir2)" #проверяю,что имя папки уже с freetype
cd $(mkfile_dir2) && sudo ./configure —prefix=$(mkfile_dir2) --enable-freetype-config --enable-static --disable-shared ; make ; sudo $(MAKE) install
Запускаю: elvin@ubuntu:~/lab1$ make static
但是 make 不起作用并发出以下错误:
make[1]: Entering directory '/home/elvin/lab1/freetype'
./builds/unix/libtool --mode=compile gcc -pedantic -ansi -I/home/elvin/lab1/freetype/objs -I./builds/unix -I/home/elvin/lab1/freetype/include -c -Wall -g -O2 -fvisibility=hidden -I/usr/local/include -I/usr/local/include/libpng16 -I/usr/local/include -DFT_CONFIG_CONFIG_H="<ftconfig.h>" -DFT2_BUILD_LIBRARY -DFT_CONFIG_MODULES_H="<ftmodule.h>" -DFT_CONFIG_OPTIONS_H="<ftoption.h>" -o /home/elvin/lab1/freetype/objs/ftsystem.lo builds/unix/ftsystem.c
libtool: compile: gcc -pedantic -ansi -I/home/elvin/lab1/freetype/objs -I./builds/unix -I/home/elvin/lab1/freetype/include -c -Wall -g -O2 -fvisibility=hidden -I/usr/local/include -I/usr/local/include/libpng16 -I/usr/local/include "-DFT_CONFIG_CONFIG_H=<ftconfig.h>" -DFT2_BUILD_LIBRARY "-DFT_CONFIG_MODULES_H=<ftmodule.h>" "-DFT_CONFIG_OPTIONS_H=<ftoption.h>" builds/unix/ftsystem.c -o /home/elvin/lab1/freetype/objs/ftsystem.o
builds/unix/ftsystem.c:19:10: fatal error: ft2build.h: No such file or directory
#include <ft2build.h>
如您所见,由于某种原因,make(manual)和makefilovsky进入了不同的目录。为什么会出现这样的错误以及如何解决?
cd
以和开头的行echo
- 这显然是你的食谱。那么这两行的开头需要一个制表符。sudo
front 。./configure
—prefix
而不是--prefix
prefix
当然不应该与源所在的目录一致。