我一直在研究Java和Python等几种编程语言,最近我开始使用C ++。我想建立一个GUI程序,最后我被建议使用FLTK,据说它是轻量级的,用户友好的。但是,我被告知要安装一系列第三方工具,而我仍然无法弄清楚如何创建一个简单的GUI应用程序。
我第一次被告知要安装一个巨大的IDE Dev-C++
并下载FLTK源代码(获得here)。然后互联网上的一些“教程”也建议我安装一个FLTK软件包(获得here),而我找不到任何关于如何实际“导入”库的教程或文档(我的意思是,类似于指定Java中的类路径和导入类)。我最终尝试将FLTK源代码复制到Dev-C ++文件夹Dev-Cpp\MinGW64\x86_64-w64-mingw32\include
,创建了一个FLTK项目并开始编译以下代码(自动生成):
/*
** Copyright © YYYY NAME
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Library General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
@file main.cpp
@author NAME
@date YYYY-MM-DD
@version 0.01
*/
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int
main(int argc, char ** argv)
{
Fl_Window *window;
Fl_Box *box;
window = new Fl_Window(300, 180);
box = new Fl_Box(20, 40, 260, 100, "Hello World!");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return(Fl::run());
}
而不是成功编译,出现的是错误消息:(从编译日志复制)
Compiling single file...
--------
- Filename: C:\C++\GUITest\main.cxx
- Compiler Name: TDM-GCC 4.9.2 32-bit Release
Processing C++ source file...
--------
- C++ Compiler: C:\Program Files\Dev-Cpp\MinGW64\bin\g++.exe
- Command: g++.exe "C:\C++\GUITest\main.cxx" -o "C:\C++\GUITest\main.exe" -m32 -std=c++11 -I"C:\Program Files\Dev-Cpp\MinGW64\include" -I"C:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"C:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib32" -static-libgcc -m32
In file included from C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/vadefs.h:9:0,
from C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/_mingw.h:282,
from C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/crtdefs.h:10,
from C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/stdio.h:9,
from C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/FL/fl_utf8.h:33,
from C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/FL/Fl.H:30,
from C:\C++\GUITest\main.cxx:26:
C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/_mingw.h:686:33: fatal error: sdks/_mingw_directx.h: No such file or directory
#include "sdks/_mingw_directx.h"
^
compilation terminated.
我真的不知道该怎么办。在我看来,C ++是一种支持缺乏和未开发的编程语言,真的很糟糕。请帮助我,或者至少给我一些提示,创建一个简单的GUI,并纠正我的误解,如果有的话。提前谢谢。