Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

c++ - FLTK version 1.3.2, Visual studio 2012 and the first example of Stroustrup's PPP book

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 FilesMicrosoft 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:UsersCSDesktopfltk-1.3.2-sourcefltk-1.3.2ideVisualC6) 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:UsersCSDesktopfltk-1.3.2-sourcefltk-          1.3.2ideVisualC6.Debug/fltk_gldllfltk_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 FilesMicrosoft Visual Studio 11.0VClib).

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

8- And also I found fltk.sln file in this path (C:UsersCSDownloadsCompressedfltk-1.3.2-sourcefltk-1.3.2ideVisualC2010). 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:UsersCSdocumentsvisual studio 2012ProjectsWin32Project1Win32Project1LINK*

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:UsersCSdocumentsvisual studio 2012ProjectsWin32Project1Win32Project1LINK

17- So I again went to the (fltk-1.3.2-sourcefltk-1.3.2lib) and copied all the .lib files except for readme, (there were 13 .lib files) and pasted them into that path (C:Program FilesMicrosoft Visual Studio 11.0VClib) 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 FilesMicrosoft Visual Studio 11.0VCinclude). 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:userscsdocumentsvisual studio 2012projectswin32project1win32project1win32project1.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:UsersCSdocumentsvisual studio 2012ProjectsWin32Project1Win32Project1Win32Project1.obj*

Now what any more effort I can to do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...