我尝试从源代码编译 surf 浏览器,但收效甚微。看来我错过了 gcr-3.pc。
编辑:我在 Ubuntu 19.04 上
c99 `pkg-config --cflags x11` `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` -DVERSION=\"2.0\" -DWEBEXTDIR=\"/usr/lib/surf\" -D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE -fPIC -O -c common.c
Package gcr-3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gcr-3.pc' to the PKG_CONFIG_PATH environment variable
echo $PKG_CONFIG_PATH 什么都没打印。我已经安装了 pkg-config ( pkg-config is already the newest version (0.29.1-0ubuntu2)
),那么我应该在哪里获取它?在其他发行版论坛上阅读有关 pkg-config 的信息显示它应该在 /usr/lib/pkgconfig 中,但我只有一个文件,ibus-table.pc
而且,surf.c:8:10: fatal error: glib.h: No such file or directory
但我确实有glib!
>> cd /usr/include/glib-2.0
>> ls -a
. gio glib.h glib-unix.h gobject
.. glib glib-object.h gmodule.h
我真的很恼火,找不到任何列出编译 surf 的依赖项的文档,甚至 surf 的自述文件也只是说“您需要 GTK+ 和 Webkit/GTK+ 头文件”。我想我已经找到了,为什么什么都不起作用?我甚至还没有修改任何东西!
完整的 make 输出(包含大量有关类型的警告):
>> sudo make clean install
rm -f surf surf.o common.o
rm -f libsurf-webext.so libsurf-webext.o
surf build options:
CC = c99
Package gcr-3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gcr-3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gcr-3' found
CFLAGS = -DVERSION="2.0" -DWEBEXTDIR="/usr/lib/surf" -D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE -fPIC -O
WEBEXTCFLAGS = -fPIC -pthread -I/usr/include/webkitgtk-4.0 -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/webkitgtk-4.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -O
LDFLAGS =
c99 -fPIC `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -O -c libsurf-webext.c
libsurf-webext.c: In function ‘msgsurf’:
libsurf-webext.c:48:42: warning: format ‘%c’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
if ((ret = snprintf(msg, sizeof(msg), "%c%c%s",
~^
%ld
2 + sln, p ? p->id : 0, s))
~~~~~~~
libsurf-webext.c:48:44: warning: format ‘%c’ expects argument of type ‘int’, but argument 5 has type ‘guint64’ {aka ‘long unsigned int’} [-Wformat=]
if ((ret = snprintf(msg, sizeof(msg), "%c%c%s",
~^
%ld
2 + sln, p ? p->id : 0, s))
~~~~~~~~~~~~~
libsurf-webext.c: In function ‘readpipe’:
libsurf-webext.c:84:2: warning: ‘webkit_dom_document_get_default_view’ is deprecated [-Wdeprecated-declarations]
if (!p || !(view = webkit_dom_document_get_default_view(
^~
In file included from /usr/include/webkitgtk-4.0/webkitdom/webkitdom.h:42,
from /usr/include/webkitgtk-4.0/webkit2/WebKitFrame.h:32,
from /usr/include/webkitgtk-4.0/webkit2/webkit-web-extension.h:33,
from libsurf-webext.c:7:
/usr/include/webkitgtk-4.0/webkitdom/WebKitDOMDocument.h:640:1: note: declared here
webkit_dom_document_get_default_view(WebKitDOMDocument* self);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libsurf-webext.c:92:3: warning: ‘webkit_dom_dom_window_get_inner_width’ is deprecated [-Wdeprecated-declarations]
ww = webkit_dom_dom_window_get_inner_width(view);
^~
In file included from /usr/include/webkitgtk-4.0/webkitdom/webkitdom.h:40,
from /usr/include/webkitgtk-4.0/webkit2/WebKitFrame.h:32,
from /usr/include/webkitgtk-4.0/webkit2/webkit-web-extension.h:33,
from libsurf-webext.c:7:
/usr/include/webkitgtk-4.0/webkitdom/WebKitDOMDOMWindow.h:371:1: note: declared here
webkit_dom_dom_window_get_inner_width(WebKitDOMDOMWindow* self);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libsurf-webext.c:93:3: warning: ‘webkit_dom_dom_window_scroll_by’ is deprecated [-Wdeprecated-declarations]
webkit_dom_dom_window_scroll_by(view,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/webkitgtk-4.0/webkitdom/webkitdom.h:40,
from /usr/include/webkitgtk-4.0/webkit2/WebKitFrame.h:32,
from /usr/include/webkitgtk-4.0/webkit2/webkit-web-extension.h:33,
from libsurf-webext.c:7:
/usr/include/webkitgtk-4.0/webkitdom/WebKitDOMDOMWindow.h:191:1: note: declared here
webkit_dom_dom_window_scroll_by(WebKitDOMDOMWindow* self, gdouble x, gdouble y);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libsurf-webext.c:99:3: warning: ‘webkit_dom_dom_window_get_inner_height’ is deprecated [-Wdeprecated-declarations]
wh = webkit_dom_dom_window_get_inner_height(view);
^~
In file included from /usr/include/webkitgtk-4.0/webkitdom/webkitdom.h:40,
from /usr/include/webkitgtk-4.0/webkit2/WebKitFrame.h:32,
from /usr/include/webkitgtk-4.0/webkit2/webkit-web-extension.h:33,
from libsurf-webext.c:7:
/usr/include/webkitgtk-4.0/webkitdom/WebKitDOMDOMWindow.h:358:1: note: declared here
webkit_dom_dom_window_get_inner_height(WebKitDOMDOMWindow* self);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libsurf-webext.c:100:3: warning: ‘webkit_dom_dom_window_scroll_by’ is deprecated [-Wdeprecated-declarations]
webkit_dom_dom_window_scroll_by(view,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/webkitgtk-4.0/webkitdom/webkitdom.h:40,
from /usr/include/webkitgtk-4.0/webkit2/WebKitFrame.h:32,
from /usr/include/webkitgtk-4.0/webkit2/webkit-web-extension.h:33,
from libsurf-webext.c:7:
/usr/include/webkitgtk-4.0/webkitdom/WebKitDOMDOMWindow.h:191:1: note: declared here
webkit_dom_dom_window_scroll_by(WebKitDOMDOMWindow* self, gdouble x, gdouble y);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c99 `pkg-config --cflags x11` `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` -DVERSION=\"2.0\" -DWEBEXTDIR=\"/usr/lib/surf\" -D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE -fPIC -O -c common.c
Package gcr-3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gcr-3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gcr-3' found
c99 -shared -Wl,-soname,libsurf-webext.so -o libsurf-webext.so \
libsurf-webext.o common.o `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0`
c99 `pkg-config --cflags x11` `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` -DVERSION=\"2.0\" -DWEBEXTDIR=\"/usr/lib/surf\" -D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE -fPIC -O -c surf.c
Package gcr-3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gcr-3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gcr-3' found
surf.c:8:10: fatal error: glib.h: No such file or directory
#include <glib.h>
^~~~~~~~
compilation terminated.
make: *** [Makefile:24: surf.o] Error 1
我在 make-ing 之前手动安装了所有这些依赖项:
build-essential
pkg-config
libglib2.0-dev
libgcc-4.8-dev
libseed-gtk4-dev
libgtk-3-dev
webkit2gtk-4.0
gdb
gdb-debug
dmenu
感谢您阅读整个文章!
答案1
在终端中,运行sudo apt update && sudo apt install libgcr-3-dev
<-- 即适用于 Ubuntu 18.04 LTS。您没有说您使用的 Ubuntu 版本是什么。