Building the examples: Fatal error: ofConstants.h: No such file or directory

I have already built the Project Generator and downloaded the external dependencies.
In the OF/ root, I ran:
➜ projectGenerator -r -o"." examples

This takes roughly 1.5 seconds. Is this suspiciously quick?
When I run make in any example directory, I get the following error:

/openFrameworks/./libs/openFrameworks/ofMain.h:6:10: fatal error: ofConstants.h: No such file or directory
** 6 | #include “ofConstants.h”**
** | ^~~~~~~~~~~~~~~compilation terminated.**

This file exists:
~/openFrameworks/examples/math/noiseField2dExample
➜ locate ofConstants.h
/home/eamoc/openFrameworks/libs/openFrameworks/utils/ofConstants.h

My spider sense tells me that this problem will continue for all include files, so hardcoding them all is not the answer…

I initially posted this under ‘beginners’, but I have reposted it as a bug, as I installed everything as directed and the problem persists…

Hi @eamoc ,

I’m assuming you are on ubuntu or raspberry pi.
you are specifying the path to openframeworks -o to be the current location, which is where the PG is located, which seems to be the error.
You should try using full path to resolve the issue.

pwd
~/OF/apps/projectGenerator/commandLine/bin

is. where my executable project generator is.
then :

./projectGenerator --help

shows me that i can use the path relative to the current executable, but i usually go for full path, such as :

./projectGenerator -o"~/OF/" -a"ofxXmlSettings, ofxOpenCv" ../../../../apps/myApps/newExample

Hope this helps,

Best,

P

Hi Pierre,
I am using Void Linux.
On the OF github page the way to build the examples is given as:

Option 2 - With the command line Project Generator

  • from the OF root directory, run projectGenerator -r -o"." examples

openFrameworks/INSTALL_FROM_GITHUB.md at master · openframeworks/openFrameworks · GitHub

I have tried every variation of the above, like hardcoding all the relevant directories, removing the -r option and specifying one example in particular. None seem to resolve the issue.
e.g.
➜ $HOME/openFrameworks/apps/projectGenerator/commandLine/bin/projectGenerator -o"$HOME/openFrameworks/" $HOME/openFrameworks/examples/shader/01_simpleColorQuad/

Upon closer inspection, I can see that the compiler does not refer to the directory that the header file lives in. ofConstants.h lives in :
/home/eamoc/openFrameworks/libs/openFrameworks/utils/
as specified above, but is not listed as an include directory:

Compiling 01_simpleColorQuad for Release
make[1]: Entering directory ‘/home/eamoc/openFrameworks/examples/shader/01_simpleColorQuad’
Compiling /home/eamoc/openFrameworks/examples/shader/01_simpleColorQuad/src/main.cpp
g++ -c -O3 -DNDEBUG -Wall -Werror=return-type -DGCC_HAS_REGEX -DOF_USING_GTK -DOF_USING_MPG123 -Wall -Werror=return-type -std=c++14 -DGCC_HAS_REGEX -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/opus -I/usr/include/AL -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/home/eamoc/openFrameworks/./libs/openFrameworks -I/home/eamoc/openFrameworks/examples/shader/01_simpleColorQuad/src -MMD -MP -MF obj/linux64/Release/src/main.d -MT obj/linux64/Release/src/main.o -o obj/linux64/Release/src/main.o -c /home/eamoc/openFrameworks/examples/shader/01_simpleColorQuad/src/main.cpp
In file included from /home/eamoc/openFrameworks/examples/shader/01_simpleColorQuad/src/main.cpp:1:
/home/eamoc/openFrameworks/./libs/openFrameworks/ofMain.h:6:10: fatal error: ofConstants.h: No such file or directory
6 | #include “ofConstants.h”
| ^~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [/home/eamoc/openFrameworks/./libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:217: obj/linux64/Release/src/main.o] Error 1
make[1]: Leaving directory ‘/home/eamoc/openFrameworks/examples/shader/01_simpleColorQuad’
make: *** [/home/eamoc/openFrameworks/./libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:129: Release] Error 2

Alright well it seems like you should be able to compile it using the command you referred to:

$HOME/OF/apps/projectGenerator/commandLine/bin/projectGenerator -o"$HOME/OF/" $HOME/OF/examples/shader/01_simpleColorQuad/

should yield something close to this :

[notice ] -----------------------------------------------
[notice ] setting OF path to: /home/pierre/OF/
[notice ] from -o option
[notice ] target platform is: linux
[notice ] updating project /home/pierre/OF/examples/shader/01_simpleColorQuad/
[notice ] parsing addons.make
[notice ] saving addons.make
[notice ] project updated!
[notice ] -----------------------------------------------


1 project updated [notice ] in 0.0330072 seconds

with respect to. your $HOME var and naming of OF install folder.

Then :

cd ~ && cd OF/examples/shader/01_simpleColorQuad
make -j$(nproc)

IF this doesn’t work, you must have a problem linked to your compiler or to your OF install.
Alternatively you can test OF/apps/myApps/emptyExample without having to re import it through the PG, as the Makefile and config.make should already be configured for your platform, This should enable you to see if your install is correctly done ( just run make -j$(nproc) from the base emptyExample folder).

I have tested the commands above with my own install running OF 0.12, it’s all working fine.

Hope this helps,

Best,

P

Its a problem with the projectGenerator I’m sure, or if not that then the documentation, as I followed it verbatim, and the problem persists.
However, if I use the PG to greate a new project, and copy the source files from the examples directory into it. The project builds and the binary executes just fine…
I’m not going to try to ferret out the particular problem, its somewhere deep in the make files, there is an extra forward slash, or something lurking around…

Did you follow the instructions above?

Can you post some logs?
Of the PG updating your files, and resulting terminal outcome?

fatal error: ofConstants.h: No such file or directory
6 | #include “ofConstants.h”
| ^~~~~~~~~~~~~~~
compilation terminated.

is a common path error which doesn’t shine light on where the prolem lays.

Best,

P

I’ve only run the project generator from its directory openFrameworks/apps/projectGenerator/commandLine/bin
and needed to pass in the relative path to OF root so the command looks like this

projectGenerator -r -o"../../../../" ../../../../examples

Hey eamoc,

I have the same issue, I haven’t investigated too deeply … my completely random and unfounded suspicion is that the instructions to build are creating a makefile that is not POSIX compliant,
so it’s working on some Linux distributions and not on others. Anyway, it’s easy to fix -
can you take a look at the config.make file? This is what is getting set up by the project generator.
Basically, by passing "." as an argument to the project generator creates a sort of funny relative / absolute hybrid path and the compiler doesn’t know how to parse it. If you just remove the dot from config.make, thereby using an absolute path for your OFROOT, the example should build okay.

################################################################################
# OF ROOT
#   The location of your root openFrameworks installation
#       (default) OF_ROOT = ../../../. 
################################################################################
OF_ROOT = /home/$USER/openFrameworks/.

becomes

OF_ROOT = /home/$USER/openFrameworks
2 Likes

Give that man a cigar!!

Problem solved. I never would have found that out

1 Like