[英]Building FLTK on Windows with Code::Blocks
I'm having a lot of trouble getting FLTK to be compliant when I try to write code in Code::Blocks. 当我尝试在Code :: Blocks中编写代码时,要使FLTK符合我很麻烦。 I'm guessing this is because I downloaded/installed it incorrectly. 我猜这是因为我错误地下载/安装了它。 I've tried to look for installation guides like 我试图寻找类似的安装指南
http://hpux.connect.org.uk/hppd/hpux/Development/Tools/fltk-1.1.9/readme.html http://hpux.connect.org.uk/hppd/hpux/Development/Tools/fltk-1.1.9/readme.html
but I don't really know what it means. 但我真的不知道这意味着什么。 I've been obtaining my source files from here. 我一直从这里获取我的源文件。
http://www.stroustrup.com/Programming/FLTK/ http://www.stroustrup.com/Programming/FLTK/
What I've tried so far is downloading the zipped folder and extracting it to my C++ folder, and then setting the IDE to search for directories in the fltk folder, but that doesn't work - I think it's a bigger problem than just looking for headers. 到目前为止,我尝试下载的是压缩文件夹并将其解压缩到C ++文件夹,然后将IDE设置为在fltk文件夹中搜索目录,但这是行不通的-我认为这是一个更大的问题,不仅仅是查找用于标题。
Can anyone with experience using FLTK point me in the right direction? 任何有使用FLTK经验的人都能为我指明正确的方向吗? Here is an example of the code used to create a simple window. 这是用于创建简单窗口的代码示例。
#include "Simple_window.h" // get access to our windows library
#include "Graph.h" // get access to graphics library facilities
int main()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib
Point tl(100,100); // to become top left corner of window
Simple_window win(tl,600,400,"Canvas"); // make a simple window
Polygon poly; // make a shape (a polygon)
poly.add(Point(300,200)); // add a point
poly.add(Point(350,100)); // add another point
poly.add(Point(400,200)); // add a third point
poly.set_color(Color::red); // adjust properties of poly
win.attach(poly); // connect poly to the window
win.wait_for_button(); // give control to display engine
}
The headers in the program can be found here if you're interested. 如果您有兴趣,可以在这里找到程序的标题。
http://www.stroustrup.com/Programming/ http://www.stroustrup.com/Programming/
Ok. 好。 You can't just unzip the darn thing into your folder. 您不能仅仅将这些坏东西解压缩到您的文件夹中。 Install Cygwin , and select gcc4-g++ during the installation process (so that g++ and its dependencies are installed). 安装Cygwin ,并在安装过程中选择gcc4-g ++(以便安装g ++及其依赖项)。 Add Cygwin to your PATH (Right Click "My Computer" -> Properties -> Advanced -> Environment Variables, create an environment variable named "CYGWIN_HOME" with the value "C:\\cygwin" or wherever cygwin is installed, edit the PATH environment variable and append ";%CYGWIN_HOME%\\bin;%CYGWIN_HOME%\\sbin;%CYGWIN_HOME%\\usr\\bin;%CYGWIN_HOME%\\usr\\sbin"). 将Cygwin添加到您的PATH(右键单击“我的电脑”->“属性”->“高级”->“环境变量”,创建一个名为“ CYGWIN_HOME”的环境变量,其值为“ C:\\ cygwin”,或者在安装了cygwin的任何地方,编辑PATH环境变量并附加“;%CYGWIN_HOME%\\ bin;%CYGWIN_HOME%\\ sbin;%CYGWIN_HOME%\\ usr \\ bin;%CYGWIN_HOME%\\ usr \\ sbin”)。 Direct Code::Blocks to use Cygwin's version of g++. 直接代码::阻止使用Cygwin的g ++版本。 Download and extract FLTK to anywhere. 将FLTK下载并解压缩到任何地方。 In that folder, run "./configure" then "make" then "sudo make install". 在该文件夹中,运行“ ./configure”,然后运行“ make”,然后运行“ sudo make install”。 Execute "fltk-config --cflags", and setup Code::Blocks to add those flags to the default compiler flags. 执行“ fltk-config --cflags”,并设置Code :: Blocks将这些标志添加到默认编译器标志。 Execute "fltk-config --ldflags" and direct Code::Blocks to add the output of that command to the default linker flags. 执行“ fltk-config --ldflags”并直接执行Code :: Blocks,以将该命令的输出添加到默认链接器标志中。
What Michael said, though you can also compile the library using Visual Studio. Michael所说的,尽管您也可以使用Visual Studio编译库。 If you look in the fltk directory, you'll see a directory called visualc
. 如果查看fltk目录,则会看到一个名为visualc
的目录。 In there is a file called fltk.dsw
. 其中有一个名为fltk.dsw
的文件。 Open that up in Visual Studio, build the project, and you should be good to go. 在Visual Studio中打开它,构建项目,您应该一切顺利。 If you're using Visual Studio 2005 or later, you want vc2005/fltk.sln
instead. 如果您使用的是Visual Studio 2005或更高版本,则需要vc2005/fltk.sln
。
The README
file in the directory you unzipped fltk into mentions this. 您将fltk解压缩到的目录中的README
文件提到了这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.