11 Replies - 1036 Views - Last Post: 04 October 2012 - 07:19 PM Rate Topic: -----

#1 InterzoneAgent  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 19-May 12

Xcode FLTK

Posted 30 September 2012 - 01:36 PM

I am using Stroustrup's book Programming: Principles and Practice. He wrote a half dozen headers to encapsulate FLTK's graphics. I have gotten the source files to work before. I am trying to set up another project with the same settings in Xcode. Here are the linker flags that I am using,

-lfltk_images
-lfltk_png
-lz
-lfltk_jpeg
-lfltk_forms
-lfltk_gl
-lfltk
-lpthread

I checked for other setting differences between the working project and the new project with Get Info on the projects. The errors are below. From the errors, my guess is that std_lib_facilities class String is being used before #include "std_lib_facilities.h" is reached by the compiler. However, I have included "std_lib_facilities.h" in exactly the same header in both projects. Any tips are appreciated. Thanks.

window.h:17:0 window.h:17: error: 'std::String' has not been declared


window.h:18:0 window.h:18: error: 'std::Vector' has not been declared


Taylor15_5.cpp:68:0 Taylor15_5.cpp:68: warning: unused variable 'n_points'


window.cpp:15: error: prototype for 'Graph_lib::Window2::Window2(int, int, const String&)' does not match any in class 'Graph_lib::Window2'
window.h:27: error: candidates are: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
window.h:32: error: Graph_lib::Window2::Window2(Point, int, int, const std::string&)
window.h:30: error: Graph_lib::Window2::Window2(int, int, const std::string&)
window.cpp:23: error: prototype for 'Graph_lib::Window2::Window2(Point, int, int, const String&)' does not match any in class 'Graph_lib::Window2'
window.cpp:15: error: candidates are: Graph_lib::Window2::Window2(int, int, const String&)
window.h:27: error: Graph_lib::Window2::Window2(const Graph_lib::Window2&)
window.h:32: error: Graph_lib::Window2::Window2(Point, int, int, const std::string&)
window.h:30: error: Graph_lib::Window2::Window2(int, int, const std::string&)

Is This A Good Question/Topic? 0
  • +

Replies To: Xcode FLTK

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Xcode FLTK

Posted 30 September 2012 - 03:04 PM

Ok, before running all over the place in search of the possible error, look at the actual error itself.

> window.h:17:0 window.h:17: error: 'std::String' has not been declared

Is windows.h your file? Then the error is in your code.

Next, the issue is std::String. Did you actually type String with a capital S? Because the type is string, not String.
Was This Post Helpful? 2
  • +
  • -

#3 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,738
  • Joined: 08-August 08

Re: Xcode FLTK

Posted 30 September 2012 - 03:24 PM

And of course, if you followed the rules and posted your code you'd probably get more specific answers sooner.
Was This Post Helpful? 1
  • +
  • -

#4 InterzoneAgent  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 19-May 12

Re: Xcode FLTK

Posted 30 September 2012 - 05:45 PM

Here is the code that I wrote. I don't see the point in posting 12 seperate source files when i doubt anyone will parse them all. String is supposed to begin with a capital because Stroustrup wrote a class called String which checks strings for error whenever a string is invoked.

/*
 *  Taylor15_5.cpp
 *  TaylorGraph
 *
 *  Created by nathaniel on 9/19/12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 *
 *	From Stroustrup's Programming: Principles and Practice
 *	Sectionn 15.5 Approximation, book example
 *
 *	The Taylor approximation gets worse with terms beyond a_13
 *	due to numerical roundoff error.
 *
 */

#include "Taylor15_5.h"
#include "../../std_lib_facilities.h"


#include "Simple_window.h"
#include "Graph.h"
#include "arc.h"
#include <stdio.h>
#include <math.h>
#include <iostream>

using namespace Graph_lib;


int fac(int n)	//factorial(n); n!
{
int r=1;
while (n>1){
r*=n;
--n;
}
return r;
}

double term(double x, int n){ return pow(x,n)/fac(n); }	//nth term of series

double expe(double x, int n)	//sum of n terms for x
{
double sum = 0;
	for (int i=0; i<n; ++i) sum+=term(x,i);
return sum;
}

int expN_number_of_terms=10;

double expN(double x)
{
return expe(x,expN_number_of_terms);
}

int main(){
	//Global constants
	const int xmax=600;
	const int ymax=400;
	
	const int x_orig=xmax/2;	//position of (0,0) is center of window
	const int y_orig=ymax/2;
	const Point orig(x_orig,y_orig);
	
	const int r_min=-10;		//range [-10:11)
	const int r_max=11;
	
	const int n_points = 400;	//number of points used in range
	
	const int x_scale = 30;		//scaling factors
	const int y_scale = 30;
	
	Simple_window win(Point(100,100),xmax,ymax,"Function graphing");
	
	for (int n = 0; n<50; ++n) {
		ostringstream ss;
		ss<<"exp approximation; n=="<< n;
		win.set_label(ss.str().c_str());
		expN_number_of_terms = n;
		//get next approximation:
		Function e(expN,r_min,r_max,orig,200,x_scale,y_scale);
		win.attach(e);
		win.wait_for_button();
		win.detach(e);
	}
}





This post has been edited by InterzoneAgent: 30 September 2012 - 05:47 PM

Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,738
  • Joined: 08-August 08

Re: Xcode FLTK

Posted 30 September 2012 - 06:17 PM

:whistling:
That code does not contain any reference to string.
Was This Post Helpful? 0
  • +
  • -

#6 InterzoneAgent  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 19-May 12

Re: Xcode FLTK

Posted 30 September 2012 - 06:35 PM

String is written in #include "../../std_lib_facilities.h"

That header file was written by Stroustrup (the Creator of C++). Similarly, the other headers and cpp files are written by Stroustrup and I have tested them in another project. I am almost certain the problem is a linking problem. Perhaps this project is reading the source files in a different order than my first project so that the String class is being used before it has been declared or defined. How can I change the order in which the files are ?preprocessed? (not sure if that is the proper term)?
Was This Post Helpful? 0
  • +
  • -

#7 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,738
  • Joined: 08-August 08

Re: Xcode FLTK

Posted 30 September 2012 - 06:44 PM

You could change the order that you include them in lines 17 - 25.
Was This Post Helpful? 0
  • +
  • -

#8 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1276
  • View blog
  • Posts: 4,395
  • Joined: 19-February 09

Re: Xcode FLTK

Posted 30 September 2012 - 07:35 PM

You seem to be having compiling errors and not linking errors.

Is this correct

#include "../../std_lib_facilities.h"




In the other headers such as Graph.h the file is only one directory/folder down.

#include "../std_lib_facilities.h"




It should be ok if there are no warnings.


You could try adding the header to std namespace.
namespace std {
#include "../../std_lib_facilities.h"
}




Apart from that you could create a simpler test program using a string/String variable and std_lib_facilities.h.

This post has been edited by #define: 30 September 2012 - 07:42 PM

Was This Post Helpful? 1
  • +
  • -

#9 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,738
  • Joined: 08-August 08

Re: Xcode FLTK

Posted 30 September 2012 - 07:43 PM

That would depend on what version of Xcode you're using, or where the compiled code or target is located.
#include "../../std_lib_facilities.h"

This post has been edited by CTphpnwb: 30 September 2012 - 07:45 PM

Was This Post Helpful? 1
  • +
  • -

#10 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1276
  • View blog
  • Posts: 4,395
  • Joined: 19-February 09

Re: Xcode FLTK

Posted 30 September 2012 - 08:15 PM

Yep, #include "file.h" will usually look in include directory after working and others. That would explain no error.
Was This Post Helpful? 0
  • +
  • -

#11 InterzoneAgent  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 19-May 12

Re: Xcode FLTK

Posted 01 October 2012 - 06:00 PM

I will try a simpler test program. Piecemeal growth is the way to steady progress.
Was This Post Helpful? 1
  • +
  • -

#12 InterzoneAgent  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 19-May 12

Re: Xcode FLTK

Posted 04 October 2012 - 07:19 PM

Got it! Apparently when I copied all the headers I missed one that had a lock symbol on the bottom left corner. I guess the lock means it has to be copied individually; it can't be copied with the group so I had missed it? Does anyone know what this lock means? I'm surprised I did not get an error that says, "GUI.h missing".
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1