Can't compile surf browser - missing /usr/include/glib.h

WiseKind

Member
Joined
May 17, 2020
Messages
39
Reaction score
7
Credits
436
I've seen this problem before after a search regarding different programs that someone can't compile because their /usr/include/glib.h is moved to /usr/include/glib-2.0/glib.h. I am having this same problem, and even though I have found other threads discussing similar problems, I have not found one that was able to solve mine.

My problem is simple. I downloaded Surf Browser from surf.suckless.org, and then tried to compile it. I have used Surf before, and it used to compile fine, but now I run into the following error. Here is the entire stdout+stderr from using make without any arguments while in the Surf build directory. Surf does not have any patches or modifications at all.
Code:
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
Package 'gcr-3', required by 'virtual:world', not found
CFLAGS        = -fPIC    -DVERSION="2.1" -DGCR_API_SUBJECT_TO_CHANGE  -DLIBPREFIX="/usr/local/lib" -DWEBEXTDIR="/usr/local/lib/surf"  -D_DEFAULT_SOURCE -O1
WEBEXTCFLAGS  = -fPIC -I/usr/include/webkitgtk-4.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 -pthread  -O1
LDFLAGS       =
c99 -fPIC `pkg-config --cflags x11` `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0`  -DVERSION=\"2.1\" -DGCR_API_SUBJECT_TO_CHANGE  -DLIBPREFIX=\"/usr/local/lib\" -DWEBEXTDIR=\"/usr/local/lib/surf\"  -D_DEFAULT_SOURCE -O1 -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
Package 'gcr-3', required by 'virtual:world', not found
surf.c:9:10: fatal error: glib.h: No such file or directory
    9 | #include <glib.h>
      |          ^~~~~~~~
compilation terminated.
make: *** [Makefile:31: surf.o] Error 1

Some of the threads tell me to do the shell command pkg-config --cflags --libs gtk+-2.0 and paste the output into the compiler's arguments. This is the output of running c99 -fPIC `pkg-config --cflags x11` `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` -DVERSION=\"2.1\" -DGCR_API_SUBJECT_TO_CHANGE -DLIBPREFIX=\"/usr/local/lib\" -DWEBEXTDIR=\"/usr/local/lib/surf\" -D_DEFAULT_SOURCE -O1 -c surf.c -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype in Surf 2.1's build directory: (I did it this way because I don't have any experience editing Makefiles)
Code:
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
Package 'gcr-3', required by 'virtual:world', not found
In file included from /usr/include/gtk-2.0/gtk/gtkobject.h:37,
                 from /usr/include/gtk-2.0/gtk/gtkwidget.h:36,
                 from /usr/include/gtk-2.0/gtk/gtkcontainer.h:35,
                 from /usr/include/gtk-2.0/gtk/gtkbin.h:35,
                 from /usr/include/gtk-2.0/gtk/gtkwindow.h:36,
                 from /usr/include/gtk-2.0/gtk/gtkdialog.h:35,
                 from /usr/include/gtk-2.0/gtk/gtkaboutdialog.h:32,
                 from /usr/include/gtk-2.0/gtk/gtk.h:33,
                 from surf.c:25:
/usr/include/gtk-2.0/gtk/gtktypeutils.h:236:1: warning: 'GTypeDebugFlags' is deprecated [-Wdeprecated-declarations]
  236 | void            gtk_type_init   (GTypeDebugFlags    debug_flags);
      | ^~~~
In file included from /usr/include/glib-2.0/gobject/gobject.h:24,
                 from /usr/include/glib-2.0/gobject/gbinding.h:29,
                 from /usr/include/glib-2.0/glib-object.h:22,
                 from /usr/include/glib-2.0/gio/gioenums.h:28,
                 from /usr/include/glib-2.0/gio/giotypes.h:28,
                 from /usr/include/glib-2.0/gio/gio.h:26,
                 from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
                 from /usr/include/gtk-2.0/gdk/gdk.h:32,
                 from surf.c:21:
/usr/include/glib-2.0/gobject/gtype.h:698:1: note: declared here
  698 | {
      | ^
In file included from /usr/include/gtk-2.0/gtk/gtktoolitem.h:31,
                 from /usr/include/gtk-2.0/gtk/gtktoolbutton.h:30,
                 from /usr/include/gtk-2.0/gtk/gtkmenutoolbutton.h:30,
                 from /usr/include/gtk-2.0/gtk/gtk.h:126,
                 from surf.c:25:
/usr/include/gtk-2.0/gtk/gtktooltips.h:73:3: warning: 'GTimeVal' is deprecated: Use 'GDateTime' instead [-Wdeprecated-declarations]
   73 |   GTimeVal last_popdown;
      |   ^~~~~~~~
In file included from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from surf.c:9:
/usr/include/glib-2.0/glib/gtypes.h:547:8: note: declared here
  547 | struct _GTimeVal
      |        ^~~~~~~~~
surf.c:26:10: fatal error: gtk/gtkx.h: No such file or directory
   26 | #include <gtk/gtkx.h>
      |          ^~~~~~~~~~~~
compilation terminated.

Now I am stuck, because doing something like pkg-config --cflags --libs gtk+-2.0 gtkx.h or pkg-config --cflags gtkx.h --libs gtk+-2.0, but those commands output something like this:
Code:
Package gtkx.h was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkx.h.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtkx.h', required by 'virtual:world', not found

I believe this would be a much easier problem to solve if I knew more about Makefiles, pkg-config, etc... But I don't, so I am asking for your help.

Hopefully I am using the correct forum. There isn't really a forum for programming tips, or maybe this is the wrong website altogether and I should be posting this on Stack Exchange or something.
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,464
Reaction score
2,079
Credits
10,249
Which Linux distro are you running?
Surf compiles fine for me on Debian 10. I still haven’t updated my apt sources to upgrade to Debian 11 yet.

I’m a long time user of many of suckless’s tools. I’m also a professional programmer, so I tend to answer a lot of the programming related questions here.

From what I’ve seen, it looks like you have newer versions of some of surfs dependencies. Which is why some of the headers are in slightly different places and is also the reason for it complaining about missing things, or warning about deprecated things.

I’m not near my PC ATM, so I can’t take a more detailed look right now.
With updated dependencies, you may need to update some of the code to get it to work with the newer versions of the libraries.

I’ll try to take a look at some point this weekend and will see if I can help you to fix this!
 
Last edited:
OP
W

WiseKind

Member
Joined
May 17, 2020
Messages
39
Reaction score
7
Credits
436
Hello. I am using Arch Linux.
This is my entire Uname output:
Code:
Linux cyb3rF0rtr3s5 5.15.2-zen1-1-zen #1 ZEN SMP PREEMPT Fri, 12 Nov 2021 19:22:07 +0000 x86_64 GNU/Linux
This is my entire Neofetch output:
Code:
[?25l[?7l[0m[36m[1m                   -`
                  .o+`
                 `ooo/
                `+oooo:
               `+oooooo:
               -+oooooo+:
             `/:-:++oooo+:
            `/++++/+++++++:
           `/++++++++++++++:
          `/+++o[0m[36m[1moooooooo[0m[36m[1moooo/`
[0m[36m[1m         [0m[36m[1m./[0m[36m[1mooosssso++osssssso[0m[36m[1m+`
[0m[36m[1m        .oossssso-````/ossssss+`
       -osssssso.      :ssssssso.
      :osssssss/        osssso+++.
     /ossssssss/        +ssssooo/-
   `/ossssso+/:-        -:/+osssso+-
  `+sso+:-`                 `.-/+oso:
 `++:.                           `-/+/
 .`                                 `/[0m
[19A[9999999D[41C[0m[1m[36m[1mwisekind[[email protected][36m[1mcyb3rF0rtr3s5[0m
[41C[0m----------------------[0m
[41C[0m[36m[1mOS[0m[0m:[0m Arch Linux x86_64[0m
[41C[0m[36m[1mHost[0m[0m:[0m Inspiron 7773[0m
[41C[0m[36m[1mKernel[0m[0m:[0m 5.15.2-zen1-1-zen[0m
[41C[0m[36m[1mUptime[0m[0m:[0m 2 hours, 57 mins[0m
[41C[0m[36m[1mPackages[0m[0m:[0m 1369 (pacman)[0m
[41C[0m[36m[1mShell[0m[0m:[0m zsh 5.8[0m
[41C[0m[36m[1mResolution[0m[0m:[0m 1920x1080, 1920x1080[0m
[41C[0m[36m[1mWM[0m[0m:[0m dwm[0m
[41C[0m[36m[1mTheme[0m[0m:[0m Solarized-Dark-Magenta [GTK2/3][0m
[41C[0m[36m[1mIcons[0m[0m:[0m breeze-extended-gnome-dark [GTK2/3][0m
[41C[0m[36m[1mTerminal[0m[0m:[0m st[0m
[41C[0m[36m[1mTerminal Font[0m[0m:[0m Hack[0m
[41C[0m[36m[1mCPU[0m[0m:[0m Intel i7-8550U (8) @ 4.000GHz[0m
[41C[0m[36m[1mGPU[0m[0m:[0m NVIDIA GeForce MX150[0m
[41C[0m[36m[1mGPU[0m[0m:[0m Intel UHD Graphics 620[0m
[41C[0m[36m[1mMemory[0m[0m:[0m 3505MiB / 15739MiB[0m

[41C[30m[40m   [31m[41m   [32m[42m   [33m[43m   [34m[44m   [35m[45m   [36m[46m   [37m[47m   [m
[41C[38;5;8m[48;5;8m   [38;5;9m[48;5;9m   [38;5;10m[48;5;10m   [38;5;11m[48;5;11m   [38;5;12m[48;5;12m   [38;5;13m[48;5;13m   [38;5;14m[48;5;14m   [38;5;15m[48;5;15m   [m


[?25h[?7h
Neofetch without color codes:
Code:
                   -`                    [email protected]
                  .o+`                   ----------------------
                 `ooo/                   OS: Arch Linux x86_64
                `+oooo:                  Host: Inspiron 7773
               `+oooooo:                 Kernel: 5.15.2-zen1-1-zen
               -+oooooo+:                Uptime: 2 hours, 57 mins
             `/:-:++oooo+:               Packages: 1369 (pacman)
            `/++++/+++++++:              Shell: zsh 5.8
           `/++++++++++++++:             Resolution: 1920x1080, 1920x1080
          `/+++ooooooooooooo/`           WM: dwm
         ./ooosssso++osssssso+`          Theme: Solarized-Dark-Magenta [GTK2/3]
        .oossssso-````/ossssss+`         Icons: breeze-extended-gnome-dark [GTK2/3]
       -osssssso.      :ssssssso.        Terminal: st
      :osssssss/        osssso+++.       Terminal Font: Hack
     /ossssssss/        +ssssooo/-       CPU: Intel i7-8550U (8) @ 4.000GHz
   `/ossssso+/:-        -:/+osssso+-     GPU: NVIDIA GeForce MX150
  `+sso+:-`                 `.-/+oso:    GPU: Intel UHD Graphics 620
 `++:.                           `-/+/   Memory: 3505MiB / 15739MiB
 .`                                 `/
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,618
Reaction score
3,325
Credits
33,512
You can just install the Surf browser using the AUR PKGBUILD.
 
OP
W

WiseKind

Member
Joined
May 17, 2020
Messages
39
Reaction score
7
Credits
436
You can just install the Surf browser using the AUR PKGBUILD.
Yeah, but I want to have modifications. As far as I know, even though Surf is available on the Arch repositories/AUR, when you install that way you can't use any patches or config.h changes, which takes away the whole point of using Suckless software. I only showed you the compilation process without modifications in order to prove that a modification wasn't a source of the issue.
 
OP
W

WiseKind

Member
Joined
May 17, 2020
Messages
39
Reaction score
7
Credits
436
UHHH GUYS?
You can just install the Surf browser using the AUR PKGBUILD.
So even though it is true that I want to use modifications on my Surf build, I decided to install aur/surf anyway, because I thought it was a better solution than my current browser (Firefox). However, it prompted the install of a dependency local/gcr. When I installed this dependency explicitly, then uninstalled aur/surf, the compile-manually version of Surf now compiles successfully. This solves my problem. Thank you both for your time.
 
OP
W

WiseKind

Member
Joined
May 17, 2020
Messages
39
Reaction score
7
Credits
436
For those of you who experience the same problem:
These are all the dependencies for Surf according to the Wiki page:
Code:
gcr (gcr-nogtk)
webkit2gtk (webkit2gtk-mse, webkit2gtk-wpe-bin, webkit2gtk-unstable)
xorg-xprop
ca-certificates (ca-certificates-utils) (optional) – SSL verification
curl (curl-git, curl-minimal-git) (optional) – default download handler
dmenu (dmenu-git, rofi-dmenu, bemenu-dmenu, dmenu-wayland-git, dmenu-rs-git, dmenu-rs, dmenu2) (optional) – URL-bar
tabbed (tabbed-git, tabbed-flexipatch-git) (optional) – tabbed frontend
xterm (jbxvt-git, xterm-git) (optional) – default download handler
Make sure you have these installed through your package manager before installing Surf the compile-manually way. This was what solved my problem.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!


Top