|
stroustrup's examples compilation |
William Labbett
Member #4,486
March 2004
|
Hi, I doing some exercises from Brian Sroustrup's book and I'm trying to compile a simple program but I get this :- Quote:
C:\Users\0_0\Desktop\stroustrup exercises\a first example>g++ -o a_first_example C:\Users\0_0\Desktop\stroustrup exercises\a first example>PAUSE I do have FL in the directory : Quote:
Microsoft Windows [Version 6.1.7601] C:\Users\0_0>cd C:\Users\0_0\Desktop\stroustrup exercises\a first example C:\Users\0_0\Desktop\stroustrup exercises\a first example>dir Directory of C:\Users\0_0\Desktop\stroustrup exercises\a first example 09/16/2011 03:32 PM <DIR> . C:\Users\0_0\Desktop\stroustrup exercises\a first example> Anyone know what I'm doing wrong ??
|
gnolam
Member #2,030
March 2002
|
Well, do you have Fl.H in said directory? -- |
William Labbett
Member #4,486
March 2004
|
Microsoft Windows [Version 6.1.7601] C:\Users\0_0>cd C:\Users\0_0\Desktop\stroustrup exercises\a first example C:\Users\0_0\Desktop\stroustrup exercises\a first example>dir Directory of C:\Users\0_0\Desktop\stroustrup exercises\a first example 09/16/2011 03:32 PM <DIR> . C:\Users\0_0\Desktop\stroustrup exercises\a first example>cd FL C:\Users\0_0\Desktop\stroustrup exercises\a first example\FL>dir Directory of C:\Users\0_0\Desktop\stroustrup exercises\a first example\FL 09/16/2011 03:35 PM <DIR> . C:\Users\0_0\Desktop\stroustrup exercises\a first example\FL> EDIT : it's looking for FL/.. in the compiler include dir Sorry about that.
|
torhu
Member #2,727
September 2002
|
You can use quotes when including, instead of < and >. Then you can keep it in a subdir of your project dir. There's also the -I switch. #include "FL/fl.h" or whatever. |
William Labbett
Member #4,486
March 2004
|
Cheers. Does anyone recognise the library I need to link to to get these functions ? : C:\Users\0_0\Desktop\stroustrup exercises\a first example>g++ -o a_first_example c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../libfltk.a(fl_dnd.obj):fl_dnd.cxx: C:\Users\0_0\Desktop\stroustrup exercises\a first example>PAUSE
|
Neil Walker
Member #210
April 2000
|
does it know where to go to find these headers/lib files? i.e. is the folder before FL in your include path? Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
William Labbett
Member #4,486
March 2004
|
I've put the files in gcc include dir now so that's not a problem anymore. I'm still having trouble compiling the example though. Can someone help ? I get this from g++ : William Labbett said:
C:\Users\0_0\Desktop\stroustrup exercises\a first example>g++ -o a_first_example C:\Users\0_0\Desktop\stroustrup exercises\a first example>PAUSE I don't understand it because in Window.h I've got : namespace Graph_lib { class Shape; // "forward declare" Shape class Widget; //------------------------------------------------------------------------------ class Window : public Fl_Window { public: // let the system pick the location: Window(int w, int h, const string& title); // top left corner in xy Window(Point xy, int w, int h, const string& title); and the prototype is here : 1
2namespace Graph_lib {
3
4Window::Window(int ww, int hh, const string& title)
5 :Fl_Window(ww,hh,title.c_str()),w(ww),h(hh)
6{
7 init();
8}
9
10//------------------------------------------------------------------------------
11
12Window::Window(Point xy, int ww, int hh, const string& title)
13 :Fl_Window(xy.x,xy.y,ww,hh,title.c_str()),w(ww),h(hh)
14{
15 init();
16}
17
18//------------------------------------------------------------------------------
19
20void Window::init()
21{
22 resizable(this);
23 show();
24}
|
Johan Halmén
Member #1,550
September 2001
|
I think your problem is that you mix C and C++.
William Labbett said: Hi, I doing some exercises from Brian Sroustrup's book and... It's Brian Kernighan (C)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
William Labbett
Member #4,486
March 2004
|
Yep, got that wrong. EDIT: it seems a bit poor that the examples don't compile.
|
torhu
Member #2,727
September 2002
|
This bit looks important Quote: g++: GUI.cpp: No such file or directory EDIT: It think you're supposed to use the files here: http://stroustrup.com/Programming/Graphics/ I've actually got the book, I wanted to see how Stroustrup himself presents C++ in a teaching context. |
William Labbett
Member #4,486
March 2004
|
Thanks torhu, I fixed that problem but I still get this :- William Labbett said:
C:\Users\0_0\Desktop\stroustrup exercises\a first example>g++ -o a_first_example C:\Users\0_0\Desktop\stroustrup exercises\a first example>PAUSE EDIT : I've looked on the google group and loads of people had problems with this stuff, so I'm going to skip it and just read the book, unless someone works it out for me here.
|
torhu
Member #2,727
September 2002
|
Quote: Window.cpp:16:12: error: 'std::String' has not been declared Should probably be std::string. Would be easier to read the error messages if you compile with -Wno-deprecated. |
William Labbett
Member #4,486
March 2004
|
okay. William Labbett said:
C:\Users\0_0\Desktop\stroustrup exercises\a first example>g++ -Wno-deprecated -o C:\Users\0_0\Desktop\stroustrup exercises\a first example>PAUSE I don't know why the capital 's' is there : the code's like this : 1#include<string>
2#include <sstream>
3#include "Window.h"
4#include "Graph.h"
5#include "GUI.h"
6
7//------------------------------------------------------------------------------
8
9
10using std::string;
11
12namespace Graph_lib {
13
14Window::Window(int ww, int hh, const string& title)
15 :Fl_Window(ww,hh,title.c_str()),w(ww),h(hh)
16{
17 init();
18}
I added the using std::string line to see if would fix the errors. <code>
|
verthex
Member #11,340
September 2009
|
Believe it or not William you can usually type the errors you have into google and just solve your problem with that.
|
Johan Halmén
Member #1,550
September 2001
|
Yes, I use that a lot. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Neil Walker
Member #210
April 2000
|
verthex said: you can usually type the errors you have into google I didn't believe you at first, but then I tried it. It works http://tinyurl.com/3btossx Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Arthur Kalliokoski
Second in Command
February 2005
|
That answer doesn't work with my problem at all! They all watch too much MSNBC... they get ideas. |
verthex
Member #11,340
September 2009
|
Arthur Kalliokoski said: That answer doesn't work with my problem at all!
Its not always a sure shot but its good at least 1/10th of the time. Neil Walker said: I didn't believe you at first, but then I tried it. It works http://tinyurl.com/3btossx And usually use quotation marks around your search. "undefined reference to IID_IDataObject"
|
|