ofxCv macro error on X11


#1

Hi :slight_smile: I cloned the ofxCv addon and tried running the Flow and Blur examples and I get this error:

/usr/include/opencv2/stitching.hpp:58:4: warning: Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers. [-W#warnings]
#  warning Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers.
   ^
/usr/include/opencv2/stitching.hpp:128:10: error: expected identifier or '{'
    enum Status
         ^
/usr/include/X11/Xlib.h:83:16: note: expanded from macro 'Status'
#define Status int
               ^
1 warning and 1 error generated.
Process failed with exit code 1.

Is it finding the wrong headers? I’m using ofxCv master (not stable) because with stable it complains about glm. I’m on Linux with QtCreator. Thank you!


#2

this is a really annoying thing with X11 they define super common names like Status as macros so you need to include anything that defines any name that classes before including ofxCv

usually if you can include ofxCv only in the cpp file just include it as the first header and it should be ok.

if you need it in your .h it can be more tricky since anything including that header needs to include it before including ofMain so trying to keep ofxCv only in your cpp will make things easier if you need to add more classes


#3

Thank you.

It seems to be more complicated. I moved everything from .h to .cpp, didn’t help. I deleted everything related to ofxCv, didn’t help. As soon as ‘ofxCv’ is listed inside of.addons in the .qbs file, I get that error.

For reference, here there’s a short explanation about this issue (which does not help):
https://bugs.freedesktop.org/show_bug.cgi?id=97359

Can I delete X11? :stuck_out_tongue:


#4

Thinking about it i remember removing all direct includes to X from the core headers but there’ might be something missing i’ll take a look when i have a moment


#5

Maybe it’s this one? https://github.com/openframeworks/openFrameworks/blob/19ec2688df9eecd818e333bef4753c302058de17/libs/openFrameworks/app/ofAppRunner.h#L111


#6

yes, that’s probably it, can you check if if works now?


#7

It does! :thumbsup:


#8

Hi, I’m having the same issue on Arch Linux, using stable branch of ofxCv and OF 0.9.8 … so what is the solution? I can’t seem to understand from your earlier conversation. Thanks for your help! Riccardo


#9

I applied this change to the OF source code:
https://github.com/openframeworks/openFrameworks/commit/ba9975971f938159466a50d4b165632f11e40d03

Moving a line from one file to another.


#10

Hi Arturo, thanks! Sorry I’m quite new to OF and C++ do I have to use the Nightly Build for Linux64 then? Or can I just make the change myself / apply patch and then recompile uising ./compileOF.sh ? I’m on 64bit ArchLinux. R


#11

Hi! It was @hamoid posting Arturo’s photo :stuck_out_tongue:

You could use the nightly build, or you can just change that one line in your OF folder.

Remove #include <X11/Xlib.h> from libs/openFrameworks/app/ofAppRunner.h and put it into libs/openFrameworks/utils/ofSystemUtils.cpp after #include <thread>

I don’t think a recompile is required. Doesn’t it happen automatically?


#12

Haha, sorry! :smile: well thank you @hamoid! I’ll give it a shot asap and report back!


#13

Damn, I’m still getting the same error @hamoid … I’ve changed the lines and even recompiled using scripts/linux/compileOF.sh (no errors) but I still get the same error when running an ofxCv example. Why could this be? Thanks for your help!

In file included from /usr/include/opencv2/opencv.hpp:86:0,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/src/ofxCv.h:4,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/example-empty/src/ofApp.h:4,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/example-empty/src/main.cpp:1:
/usr/include/opencv2/stitching.hpp:58:4: warning: #warning Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers. [-Wcpp]
 #  warning Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers.
    ^~~~~~~
In file included from /usr/include/GL/glx.h:30:0,
                 from /home/thinkpad2000/Code/openFrameworks/libs/openFrameworks/utils/ofConstants.h:184,
                 from /home/thinkpad2000/Code/openFrameworks/libs/openFrameworks/ofMain.h:5,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/example-empty/src/ofApp.h:3,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/example-empty/src/ofApp.cpp:1:
/usr/include/opencv2/stitching.hpp:128:10: error: expected identifier before ‘int’
     enum Status
          ^
In file included from /usr/include/opencv2/opencv.hpp:86:0,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/src/ofxCv.h:4,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/example-empty/src/ofApp.h:4,
                 from /home/thinkpad2000/Code/openFrameworks/addons/ofxCv/example-empty/src/ofApp.cpp:1:
/usr/include/opencv2/stitching.hpp:129:5: error: expected unqualified-id before ‘{’ token
     {

#14

Ok, maybe then @arturo should say :slight_smile: Did he remove more of those X11 includes between your version and the nightly? I see no such changes at https://github.com/openframeworks/openFrameworks/search?q=X11&type=Commits&utf8=✓

Does your code make use of ofSystemUtils.cpp, and then the X11 include ends up being part of your project, which conflicts with ofxCv’s use of the word Status?

Try the nightly? Greetings from another Arch Linux user :wink:

ps. Did you remove the line? or comment it out? I always wondered what happens if you do //#define <something>. Is the #define parsed first and replaced by the content of something, or is it ignored because of the // ?


#15

Yes I just tried the Nightly Linux64 build and it did ALMOST compile, no more X11 Status keyword error but a new one :frowning: and in the build before I removed the lines instead of commenting out

/home/thinkpad2000/Downloads/of_nightly/addons/ofxCv/libs/ofxCv/src/Flow.cpp: In member function ‘std::vector<ofVec3f> ofxCv::FlowPyrLK::getFeatures()’:
/home/thinkpad2000/Downloads/of_nightly/addons/ofxCv/libs/ofxCv/src/Flow.cpp:170:26: error: could not convert ‘poly.ofPolyline_<T>::getVertices<glm::tvec3<float, (glm::precision)0u> >()’ from ‘std::vector<glm::tvec3<float, (glm::precision)0u>, std::allocator<glm::tvec3<float, (glm::precision)0u> > >’ to ‘std::vector<ofVec3f>’
   return poly.getVertices();

#16

@hamoid Nevermind! I was using the stable branch of ofxCv - after switching back to master it compiles just fine :slight_smile: thanks a lot! I was almost thinking of going back to Ubuntu :stuck_out_tongue: although it’s probably not related to that at all anyway