在试图在我的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而消失的。
现在,这些错误是因为我的编译器不支持c++11,因为我在一个较旧的solaris10系统上。但我选择gtkmm2.4是因为我认为它也适用于较早版本的C++编译器。另外,我还试着检查是否在使用较新版本的glibmm。但是目前安装的glibmm只是我的系统的包管理器中的一个。
不知道如何进一步解决这个问题。任何建议。
发布于 2016-10-07 16:38:18
通过进行以下更改解决了该问题:
我使用以下命令安装了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 5/bin/目录中安装了很少的库和新的g++。现在,我没有使用Solaris编译器,而是使用了这个新的g++编译器,一切都很好。
但是在使用g++编译之前,我必须将LD_LIBRARY_PATH设置为:
setenv LD_LIBRARY_PATH /opt/csw/lib与新的g++编译器一样,也下载了一些库,并将其放在上面的目录中。
耶耶。:)
https://stackoverflow.com/questions/39917342
复制相似问题