ofxCv macro error on X11

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

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

1 Like

It does! :thumbsup:

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

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

Moving a line from one file to another.

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

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?

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

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
     {

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 // ?

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();

@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

Hi all,
i wonder after 5 years this issue still there…

trying to compile the computer_vision example fails.
That is the same problem as hamoid describes in here.

Target system/Environment:
Raspberry Pi 4 B / Debian Bullseye 32 Bits
gcc 10

\ ERROR: OpenCV related macro issue:

warning Detected X11 ‘Status’ macro definition, it can cause build conflicts. Please, include this header before any X11 headers.

/usr/include/opencv4/opencv2/stitching.hpp:152:10: error: expected identifier before ‘int’
152 | enum Status

/usr/include/opencv4/opencv2/stitching.hpp:153:5: error: expected unqualified-id before ‘{’ token
153 | {
| ^

/usr/include/opencv4/opencv2/stitching.hpp:152:10: error: expected identifier before ‘int’
152 | enum Status
| ^~~~~~

/usr/include/opencv4/opencv2/stitching.hpp:153:5: error: expected unqualified-id before ‘{’ token
153 | {
| ^

//

The hamoid FIX suggestion in the following files:
libs/openFrameworks/app/ofAppRunner.h
libs/openFrameworks/utils/ofSystemUtils.cpp

are already in of_v0.11.2_linuxarmv6l_release implemented. So i don’t need to change them.

how can i fix this?
Thanks for your help!

This is not an OF issue but OpenCV macro issue.
However OF should deliver consistence and error free examples that always compile on any platform OF supports.

If OF can’t compile with OpenCV than OF should point to the problem and deliver a
work around or better a fix.

The Status conflict exist only in the stitching.hpp file.
My workaround is to rename Status with XStatus.

Now i can compile OF with OpenCV.

Thanks for your help!

Thanks @Juan
Remember that OF is a community driven project, no one gets paid and there is no such thing as commanding what should be done or not. If issues arise, it is all of us who try to fix these, although as it is a voluntary thing there are times when some problems don’t get covered.
So, as you have found the solution to this problem, can you please make a Pull Request in github providing this fix? It will be really helpful and very much appreciated.

cheers

Thanks for the reply @roymacdonald

Don’t misunderstand me.

I don’t command at all. As you said , the community alone decides what should or should not be done.

My recommendation for this issue was to point out, that the quality of OF deployment can be increased with little effort.

I have created a workaround fix only for OpenCV/
of_v0.11.2_linuxarmv6l_release ruining under the raspberry pi with debian bullseye 32 bts.

It affects the /usr/include/opencv4/opencv2/stitching.hpp
file .

It has nothing to do with OF. That’s why there is no
OF pull request.

Regards
Juan


diff --git a/stitching.hpp b/stitching.hpp
index 05656a1..5d890e7 100644
--- a/stitching.hpp
+++ b/stitching.hpp
@@ -147,7 +147,7 @@ namespace cv
         static const double ORIG_RESOL;  // Initialized in stitcher.cpp
 #endif
 
-        enum Status {
+        enum EnumStatus {
             OK = 0,
             ERR_NEED_MORE_IMGS = 1,
             ERR_HOMOGRAPHY_EST_FAIL = 2,
@@ -265,13 +265,13 @@ namespace cv
 
         @param images Input images.
         @param masks Masks for each input image specifying where to look for keypoints (optional).
-        @return Status code.
+        @return EnumStatus code.
          */
-        CV_WRAP Status estimateTransform(InputArrayOfArrays images,
-                                         InputArrayOfArrays masks = noArray());
+        CV_WRAP EnumStatus estimateTransform(InputArrayOfArrays images,
+                                             InputArrayOfArrays masks = noArray());
 
         /** @overload */
-        CV_WRAP Status composePanorama(OutputArray pano);
+        CV_WRAP EnumStatus composePanorama(OutputArray pano);
         /** @brief These functions try to compose the given images (or images stored internally from
         the other function calls) into the final pano under the assumption that the image
         transformations were estimated before.
@@ -281,21 +281,21 @@ namespace cv
 
         @param images Input images.
         @param pano Final pano.
-        @return Status code.
+        @return EnumStatus code.
          */
-        CV_WRAP Status composePanorama(InputArrayOfArrays images, OutputArray pano);
+        CV_WRAP EnumStatus composePanorama(InputArrayOfArrays images, OutputArray pano);
 
         /** @overload */
-        CV_WRAP Status stitch(InputArrayOfArrays images, OutputArray pano);
+        CV_WRAP EnumStatus stitch(InputArrayOfArrays images, OutputArray pano);
         /** @brief These functions try to stitch the given images.
 
         @param images Input images.
         @param masks Masks for each input image specifying where to look for keypoints (optional).
         @param pano Final pano.
-        @return Status code.
+        @return EnumStatus code.
          */
-        CV_WRAP Status stitch(InputArrayOfArrays images, InputArrayOfArrays masks,
-                              OutputArray pano);
+        CV_WRAP EnumStatus stitch(InputArrayOfArrays images, InputArrayOfArrays masks,
+                                  OutputArray pano);
 
         std::vector<int> component() const { return indices_; }
         std::vector<detail::CameraParams> cameras() const { return cameras_; }
@@ -303,8 +303,8 @@ namespace cv
         UMat resultMask() const { return result_mask_; }
 
       private:
-        Status matchImages();
-        Status estimateCameraParams();
+        EnumStatus matchImages();
+        EnumStatus estimateCameraParams();
 
         double registr_resol_;
         double seam_est_resol_;

–eof–

I have not. No worries. Glad you are helping here.

Right, as the issue is with openCv, there is not much to be done. But maybe having a script that gets to run on the affected platforms and modifies that single openCv file.
or maybe even ignore that the stitching files in ofxOpenCv.

i could 't find any acceptable way to fix the xlib macro issue
in OF ofxOpenCv addon makefiles.

The easy way is to provide a bash script as a temporally workaround.

To keep compatibility between releases the script detects the board (raspberrypi) and eventually if is needed the OpenCV version.

The script also need elevated privileges, so the best integration is probably the install_dependecies.sh script.


  OPEN_CV_VERSION=$(/usr/bin/opencv_version)   # use if useful
  if [[ $(uname -a) == *"raspberrypi"* ]]; then
       HAVE_OPENCV_STITCHING=`grep "#define HAVE_OPENCV_STITCHING" /usr/include/opencv4/opencv2/opencv_modules.hpp`
       if [[ ${HAVE_OPENCV_STITCHING:0:7} == $"#define" ]]; then
          sed -i 's/\<Status\>/EnumStatus/' /usr/include/opencv4/opencv2/stitching.hpp
      fi
  fi

Regards
Juan

RIght, I was thinking about a bash script of some sort.
I think that this is the correct script where to add it.

It would be great if you can add to the script, check that it works fine and create a pull request for it.

all the best!

First-time contributors need a maintainer to approve running workflows.

Regards
Juan