我已经开始学习 gtkmm 编程,但第一步就卡住了。我使用的是 GNOME builder IDE 和 Ubuntu 17.10 64 位。
侏儒有一个很好的 gtkmm 教程,但构建代码在构建器中返回错误!
问题:
根据教程,源代码必须用g++编译,而builder使用gcc,因为文件名是main.c
。
mohammad@Artful-K43SD:~/Projects/test/src$ g++ main.c -o simple `pkg-config gtkmm-3.0 --cflags --libs` -no-pie
mohammad@Artful-K43SD:~/Projects/test/src$ gcc main.c -o simple `pkg-config gtkmm-3.0 --cflags --libs` -no-pie
In file included from /usr/include/glibmm-2.4/glibmm/ustring.h:21:0,
from /usr/include/glibmm-2.4/glibmm/exception.h:22,
from /usr/include/glibmm-2.4/glibmm/error.h:22,
from /usr/include/glibmm-2.4/glibmm/thread.h:47,
from /usr/include/glibmm-2.4/glibmm.h:88,
from /usr/include/gtkmm-3.0/gtkmm.h:87,
from main.c:1:
/usr/include/glibmm-2.4/glibmm/unicode.h:26:10: fatal error: cctype: No such file or directory
#include <cctype>
^~~~~~~~
compilation terminated.
make V=0 -j4 all
make all-recursive
make[1]: Entering directory '/home/mohammad/.cache/gnome-builder/builds/test/default-local-host'
Making all in data
make[2]: Entering directory '/home/mohammad/.cache/gnome-builder/builds/test/default-local-host/data'
make[2]: Leaving directory '/home/mohammad/.cache/gnome-builder/builds/test/default-local-host/data'
Making all in src
make[2]: Entering directory '/home/mohammad/.cache/gnome-builder/builds/test/default-local-host/src'
CC test-main.o
In file included from /usr/include/glibmm-2.4/glibmm/ustring.h:21:0,
from /usr/include/glibmm-2.4/glibmm/exception.h:22,
from /usr/include/glibmm-2.4/glibmm/error.h:22,
from /usr/include/glibmm-2.4/glibmm/thread.h:47,
from /usr/include/glibmm-2.4/glibmm.h:88,
from /usr/include/gtkmm-3.0/gtkmm.h:87,
from /home/mohammad/Projects/test/src/main.c:1:
/usr/include/glibmm-2.4/glibmm/unicode.h:26:10: fatal error: cctype: No such file or directory
#include <cctype>
^~~~~~~~
compilation terminated.
make[2]: *** [test-main.o] Error 1
Makefile:481: recipe for target 'test-main.o' failed
make[1]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/mohammad/.cache/gnome-builder/builds/test/default-local-host/src'
make: *** [all] Error 2
Makefile:477: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/home/mohammad/.cache/gnome-builder/builds/test/default-local-host'
Makefile:409: recipe for target 'all' failed
我只是想告诉 autotools 使用 g++.c
而不是 gcc 来处理文件。尝试编辑configure.ac
项目文件夹中的文件,但没有成功!makefile 由 builder 生成,如果我将文件添加.cpp
到项目,makefile 将不会更新!
可以在构建器中编写 gtkmm 代码吗?