Trying to link utilities class to be referenced by all the other classes

I am trying to make a Class (Utils.cpp) to be filled with “global” functions and constants that can be referenced from anywhere in my program:
I’m not too familiar with pointers so please explain your answers at length :slight_smile:


#include "Utils.hpp"

void Utils::setup(){


#ifndef Utils_hpp
#define Utils_hpp

#include <stdio.h>
#include <ofMain.h>

class Utils{
    void setup();
    ofTrueTypeFont font;
    ofImage logo;

#endif /* Utils_hpp */


void ofApp::setup(){
//Update Function (with nothing in it)
void ofApp::draw(){


#include "ofMain.h"

#include "Utils/Utils.hpp"

class ofApp : public ofBaseApp{
	void setup();
	void update();
	void draw();
  Utils util;

If anyone could help me - the error Im getting is (In Xcode)
Undefined symbols for architecture x86_64:
“Utils::setup()”, referenced from:
ofApp::setup() in ofApp.o
“Utils::Utils()”, referenced from:
ofApp::ofApp() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks! (Does this count as an advanced question?)

Hello @Zyansheep, this error is saying that you declared something in one class ofApp that has not beeing implemented.

Try to add update() implementation to your ofApp class

I do have an update() implementation in my ofApp class I just wanted to save reading time ¯_(ツ)_/¯
My main goal is to have functions and objects that can be called/used in any class in my program basically global constants.

I’m looking for an example of code that works in which I can call and use objects (like ofImage and ofTrueTypeFont) from anywhere in my program.

did you add the path to the class you are referencing (Utils.h) in the “Additional Include Directories” for the architecture you are building?

“Additional Include Directories” is the name used in Visual Studio. Xcode might be a bit different. Also I would place this question in the Beginner category since my guess is that you are starting to work with openframeworks. Advanced questions are usually topics difficult to solve, that could involve deep knowledge of computing/graphics/network issues… something that only experts can solve.

Thanks so much! I can’t believe I didn’t think of that.
When I made the files Xcode didn’t know to compile them.