Problem compiling 11.14

Get help for specific problems
Posts: 309
Joined: 7 Jan 2018

bgstack15

Hi, I am stuck on a compilation problem. I know this exact error has occurred in newer environments and I thought it was related to gcc 11, but my Devuan Ceres (Debian Sid, or unstable) environment is now throwing this error. The Arch Linux guys have had this exact problem for four months.
g++-10 -std=c++2a -pipe -DWXINTL_NO_GETTEXT_MACRO -I../.. -I../../zenXml -include "zen/i18n.h" -include "zen/warn_static.h" -Wall -Wfatal-errors -Wmissing-include-dirs -Wswitch-enum -Wcast-align -Wnon-virtual-dtor -Wno-unused-function -Wshadow -Wno-maybe-uninitialized -O3 -DNDEBUG `wx-config --cxxflags --debug=no` -pthread `pkg-config --cflags openssl` `pkg-config --cflags libcurl` `pkg-config --cflags libssh2` `pkg-config --cflags gtk+-3.0` -isystem/usr/include/gtk-3.0 `pkg-config --cflags libselinux` -DHAVE_SELINUX -c base/icon_loader.cpp -o /tmp/FreeFileSync_Make/ffs/src/base/icon_loader.cpp.o
In file included from /usr/include/wx-3.0/wx/memory.h:15,
                 from /usr/include/wx-3.0/wx/object.h:19,
                 from /usr/include/wx-3.0/wx/image.h:16,
                 from base/icon_loader.h:12,
                 from base/icon_loader.cpp:7:
/usr/include/wx-3.0/wx/string.h: In member function 'bool wxString::iterator::operator==(const wxString::const_iterator&) const':
/usr/include/wx-3.0/wx/string.h:4062:16: warning: in C++20 this comparison calls the current function recursively with reversed arguments
 4062 |     { return i == *this; }
      |              ~~^~~~~~~~
base/icon_loader.cpp: In function 'zen::FileIconHolder fff::getFileIcon(const Zstring&, int)':
base/icon_loader.cpp:219:26: error: expected primary-expression before '(' token
  219 |     return FileIconHolder(static_cast<GIcon*>(::g_object_ref(gicon)) /*pass ownership*/, maxSize);
      |                          ^
compilation terminated due to -Wfatal-errors.
make: *** [Makefile:124: /tmp/FreeFileSync_Make/ffs/src/base/icon_loader.cpp.o] Error 1
make: Leaving directory '/usr/src/freefilesync/11.14-1/FreeFileSync/Source'
My system has these gcc versions installed:
ii  gcc                                  4:10.2.1-1                         amd64        GNU C compiler
ii  gcc-10                               10.3.0-8                           amd64        GNU C compiler
ii  gcc-10-base:amd64                    10.3.0-8                           amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-11-base:amd64                    11.2.0-3                           amd64        GCC, the GNU Compiler Collection (base package)
I have explicitly set CXX=G++-10. Can anybody help me identify why this code fails to compile when it compiled fine in the past?
Posts: 309
Joined: 7 Jan 2018

bgstack15

Alright, so the problem lies within libglib2.0. When I set up my Devuan environment to use a historical snapshot of the Debian archive (see below), I was able to compile this icon_loader.cpp file.
Place in /etc/apt/sources.list:
deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20210801T144205Z/ unstable main non-free contrib
And then I was able to run:
$ sudo apt-get -V install libglib2.0-0=2.66.8-1 libglib2.0-bin=2.66.8-1 libglib2.0-data=2.66.8-1 libglib2.0-dev=2.66.8-1 libglib2.0-dev-bin=2.66.8-1 libglib2.0-0:i386=2.66.8-1
The following packages will be DOWNGRADED:
   libglib2.0-0 (2.70.0-1 => 2.66.8-1)
   libglib2.0-0:i386 (2.70.0-1 => 2.66.8-1)
   libglib2.0-bin (2.70.0-1 => 2.66.8-1)
   libglib2.0-dev (2.70.0-1 => 2.66.8-1)
   libglib2.0-dev-bin (2.70.0-1 => 2.66.8-1)
0 upgraded, 0 newly installed, 5 downgraded, 0 to remove and 2 not upgraded.
Need to get 0 B/4,704 kB of archives.
After this operation, 298 kB disk space will be freed.
Do you want to continue? [Y/n] y
Zenju, have you considered investigating how to make this compile with newer versions of libglib2.0, so 2.70.0?
Posts: 44
Joined: 14 Aug 2022

daviank

Preprocessor output for `::g_object_ref(gicon); ` is:
    ::((typename std::remove_reference<decltype (gicon)>::type) (g_object_ref) (gicon));
Since commit https://gitlab.gnome.org/GNOME/glib/-/commit/5b2bee3f539056b42c802608f9f00cc9ddd64b79
that is shipped starting from glib 2.67.0, the macro g_object_ref changed and is
also defined when __cplusplus is defined in some circumstances.

Removing the scope resolution operator `::` permits the code to build.

Could you confirm this is the correct fix?
--- a/FreeFileSync/Source/base/icon_loader.cpp
+++ b/FreeFileSync/Source/base/icon_loader.cpp
@@ -227,7 +227,11 @@ FileIconHolder fff::getFileIcon(const Zstring& filePath, int maxSize) //throw Sy
     //the remaining icon types won't block!
     assert(GDK_IS_PIXBUF(gicon) || G_IS_THEMED_ICON(gicon) || G_IS_EMBLEMED_ICON(gicon));
 
+#if (GLIB_CHECK_VERSION (2, 67, 0))
+    g_object_ref(gicon);                   //pass ownership
+#else
     ::g_object_ref(gicon);                 //pass ownership
+#endif
     return FileIconHolder(gicon, maxSize); //
 
 }
Posts: 309
Joined: 7 Jan 2018

bgstack15

Thank you, daviank, compiling with your patch works. I'll incorporate it into my package.