'' was not declared in this scope error

I am trying to very simply output some text to the screen and have been trying to get this to work for nearly 6 hours… I am completely lost at this point.

I literally copied the code from one of the example files and I get the error message. Which makes sense to me because it is right I never declared the variable. But the example file as well does not declare any variable.

here is my code:

//--------------------------------------------------------------
void ofApp::setup(){
ofBackground(25,25,25, 255);

ofTrueTypeFont::setGlobalDpi(72);

verdana14.loadFont("verdana.ttf", 14, true, true);
verdana14.setLineHeight(18.0f);
verdana14.setLetterSpacing(1.037);

bFirst = true;
typeStr = "abscedsgdsdee";

//--------------------------------------------------------------
void ofApp::draw()
{
ofSetColor(200,200,0);
ofCircle(xCord,yCord,30);
ofFill();

ofSetColor(100,100,100);
ofCircle(astX,astY,20);

ofSetColor(150);
verdana14.drawString("this I really hope this works");

Did you make sure to also copy the header file over?

Please elaborate. I know nothing of the header file…

In the source folder of the example project (and in yours if you used the project generator), you should see three files: main.cpp, ofApp.cpp, and ofApp.h. You copied the contents of ofApp.cpp from the example project into yours, but you also need the code from ofApp.h. That is the header file where the variables are declared.

It would also be a good idea to read up on some more general (not specific to open frameworks) c++ topics, such as header files. Here’s a fairly good explanation:
http://www.cplusplus.com/forum/articles/10627/

You are probably correct in saying I should learn some more about the general topics. But I was under the impression that was the point of taking a basic intro class. Then we get thrown into making a game of pong right after learning the printf statement…

Anyway I made some progress. I copied all relating variables from the header file but now get a new error message

no matching function for call to 'ofTrueTypeFont::drawstring(const char [30])

Because, indeed, there is no void ofTrueTypeFont::drawString(string s).

There is only void ofTrueTypeFont::drawString(string s, float x, float y). So, you have the string, you just need to define a position, on the window, for that string.

Please follow this link for further explanation. And keep in mind that, in the beginning, there’s a lot to learn. So it’s a good ideia to keep the OF Documentation page always open. :slight_smile:

2 Likes

Yes, hubris is absolutely right, there is a lot to take in, and it can be overwhelming at first. I would also highly recommend going through the tutorials: http://openframeworks.cc/tutorials/. They’re very well done and will save a ton of headaches, I promise.

1 Like

I cant say enough how much I appreciate all the help and the tutorials do look well written.

As well I have spend a bit of time searching the documentation.

I have spend at lease a few hours trying to figure everything out through tutorials and documentation before asking you guys for help.

You are correct now the code at least runs without error. I still don’t get any text on the screen but I think I am at least getting close at this point.

Strange, besides the missing position, I don’t see anything wrong with your code. Did you copy the font to your data folder?

I got it to work. But also found another way I think is much cleaner than what I was trying to do.

std::stringstream fmt;
fmt << "your score is"<<score;
ofDrawBitmapString(fmt.str(), 100, 100);