1

Solaris10 マシンで gtkmm サンプル コードをコンパイルしようとすると、glibmm/variant.h ヘッダーでコンパイル時エラーが発生します。

システム構成は以下のとおりです。

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

コンパイラのバージョンは次のとおりです。

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

ソース コード (sample.cc) は次のとおりです。

#include <gtkmm.h>

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

    Gtk::Window window;

    Gtk::Main::run(window);

    return 0;
}

ソースをコンパイルするコマンドは次のとおりです。

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

参考までに、pkg-config コマンドの出力を以下に示します。

> 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

以下は、私のサンプル gtkmm コードのコンパイル中に発生したエラーです。

"/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.

以前、上記のエラーを含むいくつかのエラー メッセージが表示されましたが、これらのエラーのほとんどは -library=stlport4 を含めることで解消されました。

これらのエラーは、私のコンパイラが古い solaris10 システムを使用しているため、c++11 をサポートしていなかったためです。しかし、以前のバージョンの C++ コンパイラでも動作すると考えたので、gtkmm2.4 を選択しました。また、新しいバージョンの glibmm を使用しているかどうかを確認してみました。しかし、現在インストールされている glibmm は、私のシステムのパッケージ マネージャーで利用できる 1 つだけです。

この問題を解決するためにどこを調べればよいかわかりません。助言がありますか。

4

1 に答える 1

1

この問題は、次の変更を行うことで解決されました。

以下のコマンドを使用して、Solaris システムで利用可能な最新の g++ をインストールしました。

> /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++

/opt/csw/gcc5/bin/ ディレクトリにいくつかのライブラリと新しい g++ をインストールしました。現在、Sun Solaris Compiler を使用する代わりに、この新しい g++ コンパイラを使用したところ、すべて正常に動作しました。

ただし、g++ でコンパイルする前に、LD_LIBRARY_PATH を次のように設定する必要があります。

setenv LD_LIBRARY_PATH /opt/csw/lib

新しい g++ コンパイラと同様に、いくつかのライブラリもダウンロードされ、上記のディレクトリに配置されました。

わーい。:)

于 2016-10-07T16:38:18.060 に答える