c++c++11solarisgtkmmglibmm

Error compiling gtkmm2.4 sample code on solaris10


While trying to compile gtkmm sample code on my Solaris10 machine, I am getting some compile time error in glibmm/variant.h header.

System Configuration is as below:

> uname -a
> SunOS selix570bx 5.10 Generic_150401-04 i86pc i386 i86pc

Compiler version is as below:

> CC -V
> CC: Sun C++ 5.8 2005/10/13

Source Code (sample.cc) is as below:

#include <gtkmm.h>

int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);

    Gtk::Window window;

    Gtk::Main::run(window);

    return 0;
}

Command to compile the source is as below:

> CC -library=stlport4 sample.cc -o sample `pkg-config gtkmm-2.4 --cflags --libs`

Output of pkg-config command is as below for reference:

> pkg-config gtkmm-2.4 --cflags --libs
> -I/opt/csw/include/gtkmm-2.4 -I/opt/csw/lib/gtkmm-2.4/include -I/opt/csw/include/atkmm-1.6 -I/opt/csw/include/giomm-2.4 -I/opt/csw/lib/giomm-2.4/include -I/opt/csw/include/pangomm-1.4 -I/opt/csw/lib/pangomm-1.4/include -I/opt/csw/include/gtk-2.0 -I/opt/csw/include/gtk-unix-print-2.0 -I/opt/csw/include/gdkmm-2.4 -I/opt/csw/lib/gdkmm-2.4/include -I/opt/csw/include/atk-1.0 -I/opt/csw/include/glibmm-2.4 -I/opt/csw/lib/glibmm-2.4/include -I/opt/csw/include/glib-2.0 -I/opt/csw/lib/glib-2.0/include -I/opt/csw/include/sigc++-2.0 -I/opt/csw/lib/sigc++-2.0/include -I/opt/csw/include/cairomm-1.0 -I/opt/csw/lib/cairomm-1.0/include -I/opt/csw/include/pango-1.0 -I/opt/csw/include/cairo -I/opt/csw/lib/gtk-2.0/include -I/opt/csw/include/gdk-pixbuf-2.0 -I/opt/csw/include/freetype2 -I/opt/csw/include  -L/opt/csw/lib -lgtkmm-2.4 -latkmm-1.6 -lgdkmm-2.4 -lgiomm-2.4 -lpangomm-1.4 -lgtk-x11-2.0 -lglibmm-2.4 -lcairomm-1.0 -lsigc-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 -lintl

Below is the error I am getting while compiling my sample gtkmm code:

"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1277: Error: Glib::Variant<Glib::T>::Variant() is not a member of Glib::Variant<Glib::T>.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1283: Error: Multiple declaration for<no tag>.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1296: Error: Templates can only declare classes or functions.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1300: Error: A declaration was expected instead of "return".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1301: Error: A declaration was expected instead of "}".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1304: Error: Templates can only declare classes or functions.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1307: Error: A declaration was expected instead of "return".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1307: Error: Template Variant is not defined.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1308: Error: A declaration was expected instead of "}".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1314: Error: Templates can only declare classes or functions.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1320: Error: A declaration was expected instead of "return".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1321: Error: A declaration was expected instead of "}".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1324: Error: Templates can only declare classes or functions.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1328: Error: Multiple declaration for Variant.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1328: Error: Template Variant is not defined.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: Multiple declaration for Variant.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: Template Variant is not defined.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: Use ";" to terminate declarations.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: A declaration was expected instead of ",".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: "," expected instead of ">".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: Use ";" to terminate declarations.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: A declaration was expected instead of ",".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: Multiple declaration for V.
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1330: Error: "," expected instead of ">".
"/opt/csw/include/glibmm-2.4/glibmm/variant.h", line 1333: Error: A declaration was expected instead of "return".
Compilation aborted, too many Error messages.

Earlier I got few more error messages including the above errors but most of those errors went away by including -library=stlport4.

Now, are these errors because my compiler did not support c++11 as I am on a older solaris10 system. But I choose gtkmm2.4 because I thought it works with older version of C++ compiler also. Also I tried checking if in case I am using a newer version of glibmm. But the currently installed glibmm is only one available in package manager for my system.

Not sure where to look further to resolve this issue. Any suggestions.


Solution

  • The issue got resolved by doing the following changes:

    I installed the latest g++ available for my Solaris system using below command:

    > /opt/csw/bin/pkgutil -a | grep g++
    gcc4g++              CSWgcc4g++           4.9.2,REV=2014.11.07        41.9 MB
    gcc5g++              CSWgcc5g++           5.2.0,REV=2015.07.31        57.2 MB
    > /opt/csw/bin/pkgutil -i -y gcc5g++
    

    It installed few libraries and new g++ in /opt/csw/gcc5/bin/ directory. Now, instead of using Sun Solaris Compiler I used this new g++ compiler and everything worked fine.

    But before compiling with g++ I have to set LD_LIBRARY_PATH as below:

    setenv LD_LIBRARY_PATH /opt/csw/lib
    

    As with new g++ compiler some libraries also got downloaded which got placed in above directory.

    Yayyy. :)