How to include an addon

I am trying to use https://github.com/julapy/ofxDither

following the example in https://github.com/aman-tiwari/dither-thing I have a working project, but I have ofxDither.h and ofxDither.cpp into my projects src dir. which I ‘know’ is not right.

I am pretty sure I have followed the instructions at
openframeworks. cc/learning/01_basics/how_to_add_addon_to_project/
and the faq at ofxaddons pages/howto#install

/home/carl/src/alg/goo/src/ofApp.h:6:10: fatal error: ofxDither.h: No such file or directory
6 | #include “ofxDither.h”
| ^~~~~~~~~~~~~

carl@twist:~/src/alg/goo$ cat addons.make
ofxDither

I am going out on a limb now, but shouldn’t I see addons and ofxDither in the -l’s?

make[1]: Entering directory ‘/home/carl/src/alg/goo’
Compiling /home/carl/src/alg/goo/src/ofApp.cpp
g++ -c -O3 -march=native -mtune=native -DNDEBUG -Wall -Werror=return-type -std=c++14 -DGCC_HAS_REGEX -DOF_USING_GTK -DOF_USING_GTK -pthread -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/x86_64-linux-gnu -I/usr/include/rtaudio -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/x86_64-linux-gnu/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/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/lib/x86_64-linux-gnu/glib-2.0/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/fmodex/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include/glm -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include/glm/ext -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include/glm/gtc -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include/glm/gtx -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include/glm/simd -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/glm/include/glm/detail -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/json/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/kiss/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/pugixml/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/tess2/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/utf8/include -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/utf8/include/utf8 -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/3d -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/communication -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/utils -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/graphics -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/events -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/types -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/math -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/gl -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/video -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/app -I/home/carl/of/of_v0.11.0_linux64gcc6_release//libs/openFrameworks/sound -I/home/carl/src/alg/goo/src -MMD -MP -MF obj/linux64/Release/src/ofApp.d -MT obj/linux64/Release/src/ofApp.o -o obj/linux64/Release/src/ofApp.o -c /home/carl/src/alg/goo/src/ofApp.cpp

Hey @CarlFK,
it seems that this fork is 7 years old. Then could be not updated to current OF version.

If you search on GitHub like this:

ofxDither fork:true

You can look for other forks maybe more up to date. Like this one from 2018:

I do not tested none of the repositories, but just trying to suggest some helping.

oops. I made a very fast check of this more recent repo but is not working neither.
The ofxDither.h/.cpp files are missing.
So, I tried the 2 files from the original repo,
both moved into OF/addons/ofxDither/src/
(where the ofxAddons src must be placed)
but I am having some errors too:

note: see declaration of 'ofImage_<unsigned char>::loadImage'
1>f:\openframeworks\addons\ofxdither\ditherexample\src\ofapp.cpp(52): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\ditherexample\src\ofapp.cpp(57): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(71): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(72): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(123): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(124): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(222): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(223): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(345): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(346): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(350): error C2248: 'ofImage_<unsigned char>::bpp': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(644): note: see declaration of 'ofImage_<unsigned char>::bpp'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(352): error C2440: '=': cannot convert from 'ofPixels_<unsigned char>' to 'unsigned char *'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(352): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(360): error C2440: '=': cannot convert from 'ofPixels_<unsigned char>' to 'unsigned char *'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(360): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(365): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(366): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(367): error C2248: 'ofImage_<unsigned char>::bpp': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(644): note: see declaration of 'ofImage_<unsigned char>::bpp'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(357): warning C4996: 'ofImage_<unsigned char>::getPixelsRef': Use getPixels() instead
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(411): note: see declaration of 'ofImage_<unsigned char>::getPixelsRef'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(380): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(381): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>Done building project "ditherExample.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

hey @CarlFK i had a quick look and forked the addon - there were a load of deprecated calls but have fixed the issues and both examples work now (oF v_0.11. on OSX )
you can download or fork the new addon here

to use ofxDither in your own projects (depending on your platform) you can use the project generator to make a new project then select ofxdither from the addons menu (this will just list any addons in your openframeworks/addons/ folder ) then - provided it is being called into your ofApp.h file with the

#include "ofxDither.h"

command - this will then make all the dither capabilities available to your application>>> (screenshot from Xcode on osx showing the addon linked to the project (in the folder structure in the sidebar) and explicitly added in the ofApp.h file)

1 Like

Thanks for looking at the addon and fixing it, but that does not solve my problem:

/home/carl/src/alg/goo/src/ofApp.h:6:10: fatal error: ofxDither.h: No such file or directory
6 | #include “ofxDither.h”

To double check, I cloned your update:

carl@twist:~/of/of_v20201229_linux64gcc6_release/addons$ git clone git@github.com:julapy/ofxDither.git

use the project generator to make a new project then select ofxdither from the addons menu

did that

… into your ofApp.h file with the

#include "ofxDither.h"

and that

yet still I get the error:

carl@twist:~/of/of_v0.11.0_linux64gcc6_release/apps/myApps/mySketch$ make 
...
/home/carl/of/of_v0.11.0_linux64gcc6_release/apps/myApps/mySketch/src/ofApp.h:4:10: fatal error: ofxDither.h: No such file or directory
    4 | #include "ofxDither.h"
      |          ^~~~~~~~~~~~~

If I understand, there is a command line project generator? posting screen shots of gui steps makes me grumpy :stuck_out_tongue:

Hi @CarlFK I ran a quick test this morning (i’m on OSX here) and it all works fine - maybe remove and reclone the addon and make a new project - it looks like your project is looking for the addon source files in the wrong folder?

This code works (your mileage may vary) If you cant’ get it working then i’ll run this up when i get to the studio in the week - i have several raspberry Pi running oF in Linux…

ofApp.h


#pragma once

#include "ofMain.h"
#include "ofxDither.h"

class ofApp : public ofBaseApp{

	public:
		void setup();
		void update();
		void draw();

    ofxDither dither;
    ofImage imageIn, imageOut;
};

ofApp.cpp

 #include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    imageIn.load("this-is-fine.jpg");
    // choose one from these three
    dither.dither_ordered( imageIn, imageOut, DITHER_ORDERED_8x8 );
    //  dither.dither_floyd_steinberg( imageIn, imageOut );
    // dither.dither_atkinson( imageIn, imageOut );
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
    imageIn.draw(0,0);
    imageOut.draw(0, imageOut.getHeight());    
}

@CarlFK

re-reading to check my advice was not full of holes I spotted this :

it looks like maybe you re-cloned the original addon from @julapy?

maybe try to clone again from https://github.com/danbz/ofxDither ?

@danb,
btw. I tested here on Windows/VS2017 and ditherShaderExample works.
But the other ditherExample it compiles but has (a kind of random) crashes. The example crashes here:
ofxDither.cpp

ditherExample_debug.exe!ofxDither::dither_ordered(ofImage_ & imageIn, ofImage_ & imageOut, int mapSize) Line 103 C++

@moebiussurfing thanks for checking it out and the confirmation - the ditherexample seems stable on OSX but i’ll do some more digging when i get time - I did little to the code other than update now-deprecated calls but will see what I can find…

whoops - good catch. I am sure my problem is something silly like: you cloned into the wrong directory.

and yes, this is my problem: “it looks like your project is looking for the addon source files in the wrong folder?” or as far as I can tell, it isn’t looking for addon source anywhere, it is only looking for the default libs.

in a nutshell, I say:

#include "ofxDither.h"

and the compiler says …
ok, now it is finding that file.
I am not sure how replacing that files in addons dir helped the compiler find them as I didn’t change anything in my project files.

I moved the extra ofxDitther files out of my project dir, my app runs just as it did before, and now I have less files to worry about.

so… thanks!

is it working now ? :smiley:
Good news - let me know if you see the random crashes that @moebiussurfing mentioned - i didn’t write the addon but if i can get any more info I’ll see if i can track down the bug and fix it…

you can raise an issue at https://github.com/danbz/ofxDither

Quick (pull) test and it looks the same. I don’t see new commits, maybe you forgot to push? Sorry if not…

the last push was 5 days ago… is that what you see?

yes, sorry, I misunderstood that you made new fixes yesterday.

you can raise an issue at https://github.com/danbz/ofxDither

You will need to enable Issues first, and I got an icky one for ya.

issues on the repo is now open for business ;D