FLTK版本1.3.2,Visual studio 2012和Stroustrup的PPP书的第一个例子 [英] FLTK version 1.3.2, Visual studio 2012 and the first example of Stroustrup's PPP book

查看:984
本文介绍了FLTK版本1.3.2,Visual studio 2012和Stroustrup的PPP书的第一个例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请仔细看看我想做的每个步骤,如果有任何步骤错误,请告诉我修改。



1 - 现在我有我的C:\驱动器上的MS VS 2012编译器( C:\Program Files \Microsoft Visual Studio 11.0 )。



2 - 我去了 fltk 网站并下载了版本1.3.2 ,因为我认为它是新的,所以它可以支持更好。 ( http://www.fltk.org/software.php?VERSION=1.3.2&FILE=fltk/1.3.2/fltk-1.3.2-source.tar.gz em>)



3 - 在我的桌面上解压缩该软件包后,我转到此路径( C:\Users\\ \\ CS\Desktop\fltk-1.3.2-source\fltk-1.3.2\\\\VisualC6 ),并找到fltk.dsw文件。我双击它,按OK按钮。提前选择了每个.dsp文件。



4 - 然后出现一条消息迁移解决方案项目和项目。

5 - 生成菜单中我选择了构建解决方案,然后点击它。它需要一些时间才能完成,最后,此消息出现:

  * 82> fltk_gldll.vcxproj  - > C:\Users\CS\Desktop\fltk-1.3.2-source\fltk- 1.3.2\ide\VisualC6\.\Debug / fltk_gldll\fltk_gldll.dll 
========== Build:84成功,0失败,0最新,0跳过* ==========

6 - 然后我关闭了Visual Studio,并从 FLTK 的主文件夹中打开 lib 文件夹,并将 README.lib 文件之外的七个lib文件复制到我的机器的这个路径中( C:\Program Files \Microsoft Visual Studio 11.0 \VC \ lib )。



7 - 然后我转到 FLTK FL 文件夹导入此路径( C:\Program Files \ Microsoft Visual Studio 11.0 \VC\include )。现在 include 目录包含一个名为FL的文件夹。



8 - sln 文件( C:\Users\CS\Downloads\Compressed\fltk-1.3.2-source\fltk-1.3.2\ide\VisualC2010 )。我也安装了(然后构建解决方案)。

9 - 然后我从Visual Studio创建了一个Win32项目命名为Win32Project1 。并且工作如下:



Win32Project1 - > OK - >下一步 - >点击空项目 - >完成。
在解决方案资源管理器中右键单击Win32Project1 - >选择添加 - >新项目 - >选择C ++文件(.cpp) - >将项目命名为Win32Project1 - >添加。



10 - 现在,此新项目为空,底部只有此消息: VMware Virtual Debugger loaded成功。这是为什么,因为我在我的机器上安装了VMware Workstation程序。



11 - 然后点击 - > >输入,并在其他依赖关系文本字段中,我写了以下文本: fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib



13 - 忽略特定默认库文本字段中,我写了 libcd.lib



14 - 然后 C / C ++ - > 代码生成运行时库中预先选择多线程调试DLL(/ MDd)

15 - 然后我写了1160页的简单代码( D.5

  #include< FL / F1 .h> 
#include< FL / Fl_box.h>
#include< FL / Fl_Window.h>

// ***************************

int main()
{
Fl_Window window(200,200,Window title);
Fl_Box box(0,0,200,200,嘿,我是说,He llo,World!);
window.show();
return Fl :: run();
}

16 - p>

E * rror 1错误LNK1104:无法打开文件'fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib'c:\Users\CS\ documents \visual studio 2012 \Projects\Win32Project1\Win32Project1\LINK *



所以我返回了链接器 - > 输入,并在其他依赖关系文本字段中点击了编辑... >,并将每个 .lib 文件由一个新行。又跑了。
下一个错误是:
错误1错误LNK1104:无法打开文件'fltkjpegd.lib'c:\Users\CS\documents\visual studio 2012 \Projects\ Win32Project1\Win32Project1\LINK



17 - 所以我再次去了( fltk-1.3.2 -source\fltk-1.3.2 \lib )并复制了除readme以外的所有 .lib 文件(有13个 .lib 文件)并将它们粘贴到该路径( C:\Program Files \ Microsoft Visual Studio 11.0 \VC\lib )中并重新输入代码。此时间代码成功。 WOW。



18 - 成功后,我从Stroustrup的网站下载了编程代码zip文件,并复制了所有 .h GUI 文件夹中的 .cpp 文件(10个文件)导入此路径的包含文件夹( C:\Program Files\ Microsoft Visual Studio 11.0 \VC\include )。还有一个 Makefile 文件,我没有将其复制到include目录中。然后我清除了前面的代码,并将编写在第441页(第一个示例)的代码写入该项目并运行它。

  // 
//这是第12.3节$ first $的示例代码
//Programming - Principles and Practice Using C ++by Bjarne Stroustrup
//

#includeSimple_window.h//访问我们的窗口库
#includeGraph.h//访问我们的图形库设施

// ------------------------------------------------ ------------------------------

int main()
{
使用命名空间Graph_lib; //我们的图形设施在Graph_lib中

Point tl(100,100); //成为窗口左上角

Simple_window win(tl,600,400,Canvas); // make a simple window

多边形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); //将poly连接到窗口

win.wait_for_button(); //给显示引擎以控制
}

// --------------------------- -------------------------------------------------- -

19 - 有13个错误, / p>

错误8错误C2872:'多边形':模糊符号C:\users\cs\documents\visual studio 2012\projects\win32project1 \win32project1\win32project1.cpp 20



20 - 所以我使用这个剪辑代码 Graph_lib :: Polygon poly; ,而不是此多边形poly; ,并再次运行代码。再次有11个错误,第一个是:



*错误9错误LNK2001:未解析的外部符号protected:virtual void __thiscall Graph_lib :: Window :: draw(void) (?draw @ Window @ Graph_lib @@ MAEXXZ)C:\Users\CS\documents\visual studio 2012\Projects\Win32Project1\Win32Project1\Win32Project1.obj *



现在可以做些什么呢?

解决方案

我终于找到并解决了这个问题。这是如下:



首先,不需要添加一些名为* Graph_lib *的库到链接器输入文本字段,即使我们假设在整个机器中有一个具有该名称的库!
PPP的第411页(第一个例子)的代码项目所需要做的改变是在 Polygon poly; 之前添加 Graph_lib :: 强>。之后,我们需要添加一些 .cpp 文件到项目。我将从Stroustrup网站下载的 GUI 文件夹中的所有 .cpp 文件添加到项目中(它们是 Graph.cpp strong> GUI.cpp , Simple_window.cpp window.cpp )并重新导航项目。 成功显示结果。
在任何方面,我感谢你们好人,特别是杯。


PLEASE, just look at each step that I want to do and if any step is wrong just tell me to revise it.

1- Now I have the MS VS 2012 compiler on my C:\ drive, (C:\Program Files\Microsoft Visual Studio 11.0).

2- I went to fltk website and downloaded the version 1.3.2 because I thought it’s new so it can support better. (http://www.fltk.org/software.php?VERSION=1.3.2&FILE=fltk/1.3.2/fltk-1.3.2-source.tar.gz)

3- After unzipping that package on my desktop, I went to this path (C:\Users\CS\Desktop\fltk-1.3.2-source\fltk-1.3.2\ide\VisualC6) and found the "fltk.dsw" file there. I double clicked on it and pressed OK button. Every ".dsp" file was chosen in advance.

4- Then a message appeared saying, "Migrating solution projects and items". And there were 84 items and after that some related operations occurred.

5- From the Build menu I chose Build Solution and clicked on it. It took some time to be finished and at the end, this message appeared:

           *82>  fltk_gldll.vcxproj -> C:\Users\CS\Desktop\fltk-1.3.2-source\fltk-          1.3.2\ide\VisualC6\.\Debug/fltk_gldll\fltk_gldll.dll
                  ========== Build: 84 succeeded, 0 failed, 0 up-to-date, 0 skipped* ==========

6- Then I closed the Visual Studio and from the main folder of FLTK I opened the lib folder and copied seven lib files except README.lib file into this path of my machine (C:\Program Files\Microsoft Visual Studio 11.0\VC\lib).

7- Then I went to main folder of FLTK and copied the FL folder into this path (C:\Program Files\Microsoft Visual Studio 11.0\VC\include). Now that include directory contains a folder named FL.

8- And also I found fltk.sln file in this path (C:\Users\CS\Downloads\Compressed\fltk-1.3.2-source\fltk-1.3.2\ide\VisualC2010). I installed it too (then Build Solution). Shouldn’t would I install it also?

9- I then created a "Win32 Project" from Visual Studio named it to "Win32Project1". And did the works as follows:

Win32Project1 --> OK --> Next --> Clicking on "empty project" --> Finish. In "Solution Explorer" right click on "Win32Project1" --> choosing "Add" --> new item --> choosing "C++ file (.cpp)" --> naming the project to "Win32Project1" --> Add.

10- Now this new project is empty and in bottom there is only this message: VMware Virtual Debugger loaded successfully. That’s why because I installed VMware Workstation program on my machine I think.

11- Then I clicked on Project menu and chose Properties.

12- Then Linker --> Input and in the Additional Dependencies text field, I wrote this text: fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib

13- In the Ignore Specific default Libraries text field, I wrote libcd.lib.

14- Then C/C++ --> Code Generation, and in the Runtime Library the Multi-threaded Debug DLL (/MDd) is chosen in advance. So I simply clicked on OK only.

15- Then I wrote the simple code of page 1160 (D.5) as follows on that project and pressed F5.

#include <FL/Fl.h>
#include <FL/Fl_box.h>
#include <FL/Fl_Window.h>

//***************************

int main() 
{
  Fl_Window window(200, 200, "Window title");
  Fl_Box box(0,0,200,200, "Hey, I mean, He llo, World! ");
  window.show();
  return Fl::run();
}

16- An error occurred saying:

E*rror 1 error LNK1104: cannot open file 'fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib' c:\Users\CS\documents\visual studio 2012\Projects\Win32Project1\Win32Project1\LINK*

So I returned to the Linker --> Input and in the Additional Dependencies text field, I clicked on <Edit…>, and separated each .lib file by a new line. And again ran. Next error was this: Error 1 error LNK1104: cannot open file 'fltkjpegd.lib' c:\Users\CS\documents\visual studio 2012\Projects\Win32Project1\Win32Project1\LINK

17- So I again went to the (fltk-1.3.2-source\fltk-1.3.2\lib) and copied all the .lib files except for readme, (there were 13 .lib files) and pasted them into that path (C:\Program Files\Microsoft Visual Studio 11.0\VC\lib) and reran the code. This time code succeeded. WOW.

18- So after this success I downloaded the Programming-code zip file from Stroustrup's website and copied all the .h and .cpp files (10 files) from the GUI folder into my include folder of this path (C:\Program Files\Microsoft Visual Studio 11.0\VC\include). There was also a Makefile file which I didn’t copy it into the include directory. And then I cleared the previous code and wrote the code written in page 441 (A first example) as follows into that project and ran it.

//
// This is example code from Chapter 12.3 "A first example" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//

#include "Simple_window.h"    // get access to our window library
#include "Graph.h"            // get access to our 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 the display engine
}

//------------------------------------------------------------------------------ 

19- There were 13 errors which first error was saying:

Error 8 error C2872: 'Polygon' : ambiguous symbol C:\users\cs\documents\visual studio 2012\projects\win32project1\win32project1\win32project1.cpp 20

20- So I used this snip code Graph_lib::Polygon poly; instead of this Polygon poly; and ran the code again. Again there were 11 errors, first is this:

*Error 9 error LNK2001: unresolved external symbol "protected: virtual void __thiscall Graph_lib::Window::draw(void)" (?draw@Window@Graph_lib@@MAEXXZ) C:\Users\CS\documents\visual studio 2012\Projects\Win32Project1\Win32Project1\Win32Project1.obj*

Now what any more effort I can to do?

解决方案

I finally found and solved the problem. This is as follows:

First, there is no need to add some library named *Graph_lib* into the Linker Input text field even if we assume there is a library with that name in the whole of the machine! The only needed change to be done to the project of code of page 411 (A first example) of PPP is to add the Graph_lib:: before the Polygon poly;. After that what we need is to adding some .cpp files to the project. I added all the .cpp files of GUI folder that I had downloaded them from Stroustrup's website to the project (they are Graph.cpp, GUI.cpp, Simple_window.cpp and window.cpp) and reran the project. It successfully showed the result. In any way, I'm thankful of you nice guys, especially, "cup".

这篇关于FLTK版本1.3.2,Visual studio 2012和Stroustrup的PPP书的第一个例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆