micmacIGN / micmac

Free open-source photogrammetry software tools
http://micmac.ensg.eu
Other
686 stars 150 forks source link

Compilation errors on Fedora 33 #179

Open copyme opened 2 years ago

copyme commented 2 years ago
micmac/src/SamplesLibElise/CPP_CilliaXML.cpp:43:19: error: invalid ‘static_cast’ from type ‘std::__cxx11::basic_ostringstream<char>’ to type ‘std::ostringstream&’ {aka ‘std::__cxx11::basic_ostringstream<char>&’}
   43 | #define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
micmac/src/SamplesLibElise/CPP_CilliaImgt.cpp:43:19: error: invalid ‘static_cast’ from type ‘std::__cxx11::basic_ostringstream<char>’ to type ‘std::ostringstream&’ {aka ‘std::__cxx11::basic_ostringstream<char>&’}
   43 | #define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have gcc 11.2.1.

Micmac-test commented 2 years ago

PClinuxOS. gcc 11.2.0 The same result.

MartheusX commented 2 years ago

Ubuntu Studio 21.10 gcc 11.2.0 Same result

SammyTheSnake commented 2 years ago

Debian bookworm (testing - as of 2022-02-07) gcc 11.2.0-14 Same result

I compiled commit 637e8319afa9d1b285a745c5a715609ce5f58f59 "Merge branch 'master' of https://github.com/micmacIGN/micmac" (latest as of today- only a few hours old)

Compiling the commit tagged "v1.0-beta14" also gives the same result

SammyTheSnake commented 2 years ago

So, I've had a go at fixing this as it appears whoever wrote the relevant code either had some juju on their side or hasn't ever tried to compile it because it's an unambiguously incorrect bit of code (also, we've only had comments from people hitting the problem, and none that appear to know how to fix it (I don't consider myself an exception to that!)

The problem appears to be an attempt to cast an object to an object pointer which isn't something you can do by a cast. Just removing the "&" on the two offending lines would probably work, (the compilation completes for me...) but looking a little closer, it appears that somebody spotted the error already and applied a slightly over-cautious fix (https://github.com/micmacIGN/micmac/commit/cdd513ec345fa5d087e2b160a218eca30aa73ff1)

Anyway, by applying this "MacOS" fix a little more widely, I think I might have the solution...?

I sought hard for an option to forego compiling these files, as they appear to be essentially irrelevant (They appear to be examples for a library, rather than actually part of micmac) but failed miserably. Perhaps that was the juju involved in this never coming to the attention of anyone more knowledgeable than me...

In a semi-related note - the CMAKE_INSTALL_PREFIX configuration doesn't seem to be doing what I'd expect, but that's as likely to be my own inadequacies coming through, so I'll hold off creating an issue for that until I've done some more poking about :-P

patch (by a tool who knows very very little about C++!):

diff --git a/src/SamplesLibElise/CPP_CilliaImgt.cpp b/src/SamplesLibElise/CPP_CilliaImgt.cpp
index dbc0dc8..92dce3b 100755
--- a/src/SamplesLibElise/CPP_CilliaImgt.cpp
+++ b/src/SamplesLibElise/CPP_CilliaImgt.cpp
@@ -37,11 +37,7 @@ Header-MicMac-eLiSe-25/06/2007*/

 #include "StdAfx.h"
-#if (ELISE_MacOs)
 #define SSTR( x ) (std::ostringstream()<< std::dec << x).str()
-#else
-#define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
-#endif

 int CilliaImgt_main(int argc, char ** argv)
 {
diff --git a/src/SamplesLibElise/CPP_CilliaXML.cpp b/src/SamplesLibElise/CPP_CilliaXML.cpp
index 55ae406..5c2a0b6 100755
--- a/src/SamplesLibElise/CPP_CilliaXML.cpp
+++ b/src/SamplesLibElise/CPP_CilliaXML.cpp
@@ -37,11 +37,7 @@ English :
 Header-MicMac-eLiSe-25/06/2007*/

 #include "StdAfx.h"
-#if (ELISE_MacOs)
 #define SSTR( x ) (std::ostringstream()<< std::dec << x).str()
-#else
-#define SSTR( x ) static_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
-#endif

 int HomToXML_main( int argc , char ** argv)
 {