CMake compile project with different GCC/G++ - c++

I have a project that compiles on Ubuntu with gcc and g++ 7.5. For some reason it does not compile with the latest G++ on my Arch.
For some reason, std::atomic_bool is not found, even though the exact same code compiles in Ubuntu.
I installed gcc and g++ 7.5 onto my Arch, and then ran the following as per here:
export CC=/usr/bin/gcc-7
export CXX=/usr/bin/g++-7
cmake ..
make -j12
But it did not work, and failed with the same message as if I tried to build with gcc-10. I tried all different variations, like the following, but none of them worked.
cmake -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 ..
Am I missing anything?
Here is the terminal output
[seedship#triple-destinies cpsCore]$ mkdir build
[seedship#triple-destinies cpsCore]$ cd build/
[seedship#triple-destinies build]$ export CC=/usr/bin/gcc-7
[seedship#triple-destinies build]$ export CXX=/usr/bin/g++-7
[seedship#triple-destinies build]$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-7 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-7 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib64/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0") found components: system
Compiling with NODEBUG
-- Configuring done
-- Generating done
-- Build files have been written to: /home/seedship/cpsCore/build
[seedship#triple-destinies build]$ make -j12
Scanning dependencies of target cps_core
[ 4%] Building CXX object src/CMakeFiles/cps_core.dir/Aggregation/Aggregator.cpp.o
[ 4%] Building CXX object src/CMakeFiles/cps_core.dir/Aggregation/DynamicContainer/DynamicObjectContainer.cpp.o
[ 6%] Building CXX object src/CMakeFiles/cps_core.dir/Configuration/JsonPopulator.cpp.o
[ 11%] Building CXX object src/CMakeFiles/cps_core.dir/Configuration/TerminalConfigurator.cpp.o
[ 11%] Building CXX object src/CMakeFiles/cps_core.dir/Configuration/Configuration.cpp.o
[ 13%] Building CXX object src/CMakeFiles/cps_core.dir/Synchronization/AggregatableRunner.cpp.o
[ 16%] Building CXX object src/CMakeFiles/cps_core.dir/Synchronization/SimpleRunner.cpp.o
[ 18%] Building CXX object src/CMakeFiles/cps_core.dir/Synchronization/SynchronizedRunner.cpp.o
[ 20%] Building CXX object src/CMakeFiles/cps_core.dir/Synchronization/SynchronizedRunnerMaster.cpp.o
[ 23%] Building CXX object src/CMakeFiles/cps_core.dir/Framework/PluginManager.cpp.o
[ 25%] Building CXX object src/CMakeFiles/cps_core.dir/Framework/Helper.cpp.o
[ 27%] Building CXX object src/CMakeFiles/cps_core.dir/Logging/CPSLogger.cpp.o
[ 30%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/LinearAlgebra.cpp.o
In file included from /home/seedship/cpsCore/src/Configuration/TerminalConfigurator.cpp:5:0:
/home/seedship/cpsCore/include/cpsCore/Configuration/TerminalConfigurator.h: In member function ‘bool TerminalConfigurator::configure(ConfObj&)’:
/home/seedship/cpsCore/include/cpsCore/Configuration/TerminalConfigurator.h:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
/home/seedship/cpsCore/include/cpsCore/Configuration/TerminalConfigurator.h: In member function ‘TerminalConfigurator& TerminalConfigurator::operator&(Param&)’:
/home/seedship/cpsCore/include/cpsCore/Configuration/TerminalConfigurator.h:67:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
[ 32%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/Packet.cpp.o
[ 34%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/SignalHandler/SignalHandler.cpp.o
[ 37%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/TimeProvider/SystemTimeProvider.cpp.o
[ 39%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/Scheduler/MicroSimulator.cpp.o
[ 41%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/Scheduler/ExternalSimulator.cpp.o
[ 44%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/Scheduler/MultiThreadingScheduler.cpp.o
[ 46%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/Scheduler/Event.cpp.o
In file included from /usr/include/boost/property_tree/json_parser/detail/parser.hpp:7:0,
from /usr/include/boost/property_tree/json_parser/detail/read.hpp:13,
from /usr/include/boost/property_tree/json_parser.hpp:16,
from /home/seedship/cpsCore/src/Framework/Helper.cpp:7:
/usr/include/boost/bind.hpp:41:1: note: #pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.
)
^
In file included from /usr/include/boost/property_tree/json_parser/detail/parser.hpp:7:0,
from /usr/include/boost/property_tree/json_parser/detail/read.hpp:13,
from /usr/include/boost/property_tree/json_parser.hpp:16,
from /home/seedship/cpsCore/src/Configuration/Configuration.cpp:5:
/usr/include/boost/bind.hpp:41:1: note: #pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.
)
^
[ 48%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/Scheduler/EventBody.cpp.o
[ 51%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IPC/IPC.cpp.o
[ 53%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IPC/Subscription.cpp.o
[ 55%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp.o
[ 58%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp.o
[ 60%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IPC/detail/MessageQueuePublisherImpl.cpp.o
[ 62%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IPC/detail/SharedMemoryPublisherImpl.cpp.o
[ 65%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IDC/NetworkLayer/Serial/SerialHandler.cpp.o
[ 67%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IDC/NetworkLayer/Serial/SerialNetworkLayer.cpp.o
[ 69%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IDC/NetworkLayer/Redis/RedisPublisher.cpp.o
In file included from /home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:11:0:
/home/seedship/cpsCore/include/cpsCore/Utilities/IPC/detail/MessageQueueSubscriptionImpl.h:45:7: error: ‘atomic_bool’ in namespace ‘std’ does not name a type
std::atomic_bool listenerCanceled_;
^~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp: In constructor ‘MessageQueueSubscriptionImpl::MessageQueueSubscriptionImpl(const string&, std::size_t)’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:15:62: error: class ‘MessageQueueSubscriptionImpl’ does not have any field named ‘listenerCanceled_’
messageQueue_(boost::interprocess::open_only, id.c_str()), listenerCanceled_(false), maxPacketSize_(
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp: In destructor ‘virtual MessageQueueSubscriptionImpl::~MessageQueueSubscriptionImpl()’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:22:7: error: ‘listenerCanceled_’ was not declared in this scope
if (!listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:22:7: note: suggested alternative: ‘listenerThread_’
if (!listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
listenerThread_
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp: In member function ‘virtual void MessageQueueSubscriptionImpl::cancel()’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:31:2: error: ‘listenerCanceled_’ was not declared in this scope
listenerCanceled_.store(true);
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:31:2: note: suggested alternative: ‘listenerThread_’
listenerCanceled_.store(true);
^~~~~~~~~~~~~~~~~
listenerThread_
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp: In member function ‘void MessageQueueSubscriptionImpl::onMessageQueue()’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:54:7: error: ‘listenerCanceled_’ was not declared in this scope
if (listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:54:7: note: suggested alternative: ‘listenerThread_’
if (listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
listenerThread_
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:79:7: error: ‘listenerCanceled_’ was not declared in this scope
if (listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp:79:7: note: suggested alternative: ‘listenerThread_’
if (listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
listenerThread_
In file included from /home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:12:0:
/home/seedship/cpsCore/include/cpsCore/Utilities/IPC/detail/SharedMemorySubscriptionImpl.h:47:7: error: ‘atomic_bool’ in namespace ‘std’ does not name a type
std::atomic_bool listenerCanceled_;
^~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp: In constructor ‘SharedMemorySubscriptionImpl::SharedMemorySubscriptionImpl(const string&)’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:18:92: error: class ‘SharedMemorySubscriptionImpl’ does not have any field named ‘listenerCanceled_’
sharedMem_(boost::interprocess::open_only, id.c_str(), boost::interprocess::read_write), listenerCanceled_(
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp: In member function ‘virtual void SharedMemorySubscriptionImpl::cancel()’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:33:2: error: ‘listenerCanceled_’ was not declared in this scope
listenerCanceled_.store(true);
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:33:2: note: suggested alternative: ‘listenerThread_’
listenerCanceled_.store(true);
^~~~~~~~~~~~~~~~~
listenerThread_
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp: In destructor ‘virtual SharedMemorySubscriptionImpl::~SharedMemorySubscriptionImpl()’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:40:7: error: ‘listenerCanceled_’ was not declared in this scope
if (!listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:40:7: note: suggested alternative: ‘listenerThread_’
if (!listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
listenerThread_
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp: In member function ‘void SharedMemorySubscriptionImpl::onSharedMemory()’:
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:73:7: error: ‘listenerCanceled_’ was not declared in this scope
if (listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
/home/seedship/cpsCore/src/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp:73:7: note: suggested alternative: ‘listenerThread_’
if (listenerCanceled_.load())
^~~~~~~~~~~~~~~~~
listenerThread_
In file included from /home/seedship/cpsCore/include/cpsCore/Utilities/IPC/IPC.h:14:0,
from /home/seedship/cpsCore/src/Utilities/Scheduler/ExternalSimulator.cpp:7:
/home/seedship/cpsCore/include/cpsCore/Utilities/IPC/detail/SharedMemorySubscriptionImpl.h:47:7: error: ‘atomic_bool’ in namespace ‘std’ does not name a type
std::atomic_bool listenerCanceled_;
^~~~~~~~~~~
[ 72%] Building CXX object src/CMakeFiles/cps_core.dir/Utilities/IDC/NetworkLayer/Redis/RedisSubscriber.cpp.o
make[2]: *** [src/CMakeFiles/cps_core.dir/build.make:381: src/CMakeFiles/cps_core.dir/Utilities/IPC/detail/MessageQueueSubscriptionImpl.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [src/CMakeFiles/cps_core.dir/build.make:394: src/CMakeFiles/cps_core.dir/Utilities/IPC/detail/SharedMemorySubscriptionImpl.cpp.o] Error 1
make[2]: *** [src/CMakeFiles/cps_core.dir/build.make:303: src/CMakeFiles/cps_core.dir/Utilities/Scheduler/ExternalSimulator.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:443: src/CMakeFiles/cps_core.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

Related

CGAL namespace does not contain data_file_path function

I am using xubuntu20.04 and trying out to compile an example of cgal. for reference, I am working with AABB_tree. CGAL is header only so I copied the include folder to AABB_tree directory. Followed this instruction. when I run make this error is generated-
Scanning dependencies of target AABB_segment_3_example
[ 3%] Building CXX object CMakeFiles/AABB_segment_3_example.dir/AABB_segment_3_example.cpp.o
[ 7%] Linking CXX executable AABB_segment_3_example
[ 7%] Built target AABB_segment_3_example
Scanning dependencies of target AABB_custom_indexed_triangle_set_array_example
[ 10%] Building CXX object CMakeFiles/AABB_custom_indexed_triangle_set_array_example.dir/AABB_custom_indexed_triangle_set_array_example.cpp.o
[ 14%] Linking CXX executable AABB_custom_indexed_triangle_set_array_example
[ 14%] Built target AABB_custom_indexed_triangle_set_array_example
Scanning dependencies of target AABB_polyhedron_facet_distance_example
[ 17%] Building CXX object CMakeFiles/AABB_polyhedron_facet_distance_example.dir/AABB_polyhedron_facet_distance_example.cpp.o
[ 21%] Linking CXX executable AABB_polyhedron_facet_distance_example
[ 21%] Built target AABB_polyhedron_facet_distance_example
Scanning dependencies of target AABB_halfedge_graph_edge_example
[ 25%] Building CXX object CMakeFiles/AABB_halfedge_graph_edge_example.dir/AABB_halfedge_graph_edge_example.cpp.o
[ 28%] Linking CXX executable AABB_halfedge_graph_edge_example
[ 28%] Built target AABB_halfedge_graph_edge_example
Scanning dependencies of target AABB_cached_bbox_example
[ 32%] Building CXX object CMakeFiles/AABB_cached_bbox_example.dir/AABB_cached_bbox_example.cpp.o
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp: In function ‘void triangle_mesh(std::string)’:
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:30:17: error: ‘read_polygon_mesh’ is not a member of ‘CGAL::IO’
30 | if(!CGAL::IO::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))
| ^~~~~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp: In function ‘int main(int, char**)’:
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:86:54: error: ‘data_file_path’ is not a member of ‘CGAL’
86 | triangle_mesh<Polyhedron_3>((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
| ^~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:89:54: error: ‘data_file_path’ is not a member of ‘CGAL’
89 | triangle_mesh<Surface_mesh>((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
| ^~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:92:50: error: ‘data_file_path’ is not a member of ‘CGAL’
92 | surface_mesh_cache_bbox((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
| ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/AABB_cached_bbox_example.dir/build.make:63: CMakeFiles/AABB_cached_bbox_example.dir/AABB_cached_bbox_example.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:266: CMakeFiles/AABB_cached_bbox_example.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
It looks like cgal namespace does not include a data_file_path function. How to fix the problem? Is there any linking problem exist?
I have copied the meshes/tetrahedron.off to the AABB_tree directory. Since the function does not exist, no way to read it.

Error building and linking OpenCV when built with LLVM and mingw under windows

I cannot build OpenCV under windows with llvm(From www.llvm.org)
and Mingw(from https://github.com/niXman/mingw-builds-binaries/releases).
While everything seems to build
correctly, it fails to link and the whole compilation stops as follows:
[ 9%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/split.avx2.cpp.obj
[ 9%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/sum.avx2.cpp.obj
[ 9%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/matmul.avx512_skx.cpp.obj
[ 9%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
[ 9%] Linking CXX shared library ..\..\bin\libopencv_core460.dll
There are tons of messages that indicate that I cannot link to pthread
C:\Users\akar\bin\mingw\mingw64\bin\ld.exe: CMakeFiles\opencv_core.dir/objects.a(system.cpp.obj):system.cpp:(.text$_ZN2cv5errorERKNS_9ExceptionE[_ZN2cv5errorERKNS_9ExceptionE]+0x34): undefined reference to `pthread_mutex_lock'
C:\Users\akar\bin\mingw\mingw64\bin\ld.exe: CMakeFiles\opencv_core.dir/objects.a(system.cpp.obj):system.cpp:(.text$_ZN2cv5errorERKNS_9ExceptionE[_ZN2cv5errorERKNS_9ExceptionE]+0xc5): undefined reference to `pthread_mutex_unlock'
C:\Users\akar\bin\mingw\mingw64\bin\ld.exe: CMakeFiles\opencv_core.dir/objects.a(system.cpp.obj):system.cpp:(.text$_ZN2cv5errorERKNS_9ExceptionE[_ZN2cv5errorERKNS_9ExceptionE]+0x176): undefined reference to `pthread_mutex_unlock'
From my bash environment I have defined the following:
export CC="clang.exe -target x86_64-pc-windows-gnu"
export CXX="clang++.exe -target x86_64-pc-windows-gnu"
export CMAKE_GENERATOR="MinGW Makefiles"
if I don't specify the -target argument in clang msvc builds correctly. If i try to cheat
the linker by setting
alias ld="ld -lpthread"
I get this nice error
C:/Users/akar/source/repos/opencv/modules/core/include\opencv2/core/utility.hpp:718:9: error: no type named 'recursive_mutex' in namespace 'std'; did you mean '__gnu_cxx::__recursive_mutex'?
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~~~~~~
__gnu_cxx::__recursive_mutex
C:\Users\akar\bin\mingw\mingw64\lib\gcc\x86_64-w64-mingw32\12.1.0\include\c++\ext/concurrence.h:170:9: note: '__gnu_cxx::__recursive_mutex' declared here
class __recursive_mutex
^
1 error generated.

Linker error while building a ROOT class "RooUnfold" in Mac using cmake

What I want to do
I want to build a ROOT class "RooUnfold" in Mac.
Question
How can I solve linker errors (ld: library not found for -lgcov clang: error: linker command failed with exit code 1 (use -v to see invocation)) which occurs when I tried to build RooUnfold using cmake?
What I did
(1) I installed ROOT on my Mac. It successfully works.
(2) I downloaded and unzipped "RooUnfold-master.zip" from a web cite(https://gitlab.cern.ch/RooUnfold/RooUnfold).
(3) I tried to build RooUnfold following the instructions on the web cite as following :
cd RooUnfold-master
mkdir build
cd build
cmake ..
make -j4
cd ..
source build/setup.sh
(4) However, it was failed when I tried make -j4 with following output :
$ cd RooUnfold-master
$ mkdir build
$ cd build
$ cmake ..
CMake Deprecation Warning at CMakeLists.txt:10 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Setup using plain ROOT
Doxygen build started
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/XXXXXX/RooUnfold-master/build
$ make -j4
[ 2%] Generating G__RooUnfold.cxx, libRooUnfold_rdict.pcm, libRooUnfold.rootmap
Scanning dependencies of target RooUnfold
[ 9%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooUnfoldBayes.o
[ 9%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooUnfold.o
[ 9%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooFitUnfold.o
[ 12%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooUnfoldBinByBin.o
In file included from /Users/XXXXXX/RooUnfold-master/src/RooUnfoldBinByBin.cxx:8:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBinByBin.h:44:3: warning: 'CheckTObjectHashConsistency' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
ClassDefT (RooUnfoldBinByBinT, 1) // Bin-by-bin unfolding
^
/opt/homebrew/Cellar/root/6.26.04_1/include/root/Rtypes.h:392:4: note: expanded from macro 'ClassDefT'
_ClassDefOutline_(name,id,virtual,) \
^
/opt/homebrew/Cellar/root/6.26.04_1/include/root/Rtypes.h:300:4: note: expanded from macro '_ClassDefOutline_'
_ClassDefBase_(name,id, virtual_keyword, overrd) \
^
(a lot of "override" errors)
97 warnings generated.
[ 63%] Linking CXX shared library libRooUnfold.dylib
[ 63%] Built target RooUnfold
[ 73%] Building CXX object CMakeFiles/RooUnfoldTest3D.dir/test/src/RooUnfoldTest3D.o
[ 73%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/generate_test.o
[ 73%] Building CXX object CMakeFiles/RooUnfoldTest2D.dir/test/src/RooUnfoldTest2D.o
[ 73%] Building CXX object CMakeFiles/RooUnfoldTest.dir/test/src/RooUnfoldTest.o
[ 75%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/response_test.o
[ 78%] Linking CXX executable RooUnfoldTest
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [RooUnfoldTest] Error 1
make[1]: *** [CMakeFiles/RooUnfoldTest.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 80%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/bayes_test.o
[ 82%] Linking CXX executable RooUnfoldTest2D
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [RooUnfoldTest2D] Error 1
make[1]: *** [CMakeFiles/RooUnfoldTest2D.dir/all] Error 2
[ 85%] Linking CXX executable RooUnfoldTest3D
[ 87%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/RooUnfold_unit_tests.o
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [RooUnfoldTest3D] Error 1
make[1]: *** [CMakeFiles/RooUnfoldTest3D.dir/all] Error 2
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:45:17: warning: 'SetRegParm' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual void SetRegParm (Double_t parm);
^
/Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:31:20: note: in instantiation of template class 'RooUnfoldBayesT<TH1, TH2>' requested here
RooUnfoldBayes unfold(&response, h_meas, 4);
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:115:22: note: overridden virtual function is here
virtual void SetRegParm (Double_t parm);
^
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:46:18: warning: 'GetRegParm' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual double GetRegParm() const;
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:116:22: note: overridden virtual function is here
virtual Double_t GetRegParm() const; // Get Regularisation Parameter
^
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:47:16: warning: 'Reset' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual void Reset();
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:74:16: note: overridden virtual function is here
virtual void Reset ();
^
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:48:16: warning: 'Print' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual void Print (Option_t* option= "") const;
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:129:8: note: overridden virtual function is here
void Print(Option_t* opt="") const;
^
/Users/XXXXXX/RooUnfold-master/test/src/RooUnfold_unit_tests.cxx:29:62: warning: format specifies type 'unsigned int' but the argument has type 'std::vector<float>::size_type' (aka 'unsigned long') [-Wformat]
check(n==r.size(), "error in bayes: %d bins is not %u",n,r.size());
~~ ^~~~~~~~
%lu
/Users/XXXXXX/RooUnfold-master/test/src/dbg.h:30:18: note: expanded from macro 'check'
log_err(M, ##__VA_ARGS__); errno=0; goto error; }
~ ^~~~~~~~~~~
/Users/XXXXXX/RooUnfold-master/test/src/dbg.h:20:26: note: expanded from macro 'log_err'
clean_errno(), ##__VA_ARGS__)
^~~~~~~~~~~
4 warnings generated.
1 warning generated.
[ 90%] Linking CXX static library libRooUnfoldTests.a
[ 90%] Built target RooUnfoldTests
make: *** [all] Error 2
(5) I think the linker errors such as ld: library not found for -lgcov clang: error: linker command failed with exit code 1 (use -v to see invocation) are fatal, but I could not solve them.
Environment
Mac OS : Monterey ver. 12.3
chip : Apple M1 Pro
ROOT : ver. 6.26
$ root --version
ROOT Version: 6.26/04
Built for macosxarm64 on Jun 07 2022, 16:01:16
From tags/v6-26-04#v6-26-04
gcc : ver. 13.1.6
$ gcc --version
Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
cmake : ver. 3.22.3
$ cmake --version
cmake version 3.22.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
I think the problem lies in the CMakeLists.txt file. How have to link it. how you would do that is as follows:
...
find_package(ROOT)
...
target_link_libraries(${ROOT_LIBRARIES})
...
I built RooUnfold successfully by using another CMakeFile.txt at https://gitlab.cern.ch/RooUnfold/RooUnfold/-/tree/CMakeLists-fix.
I have not understood the difference completely yet.
However, it may be better to install not from "master", but from "CMakeLists-fix" for Mac users who want to use RooUnfold.

Cross platform compilation problem on linux: error: new_allocator.h:93:7: error: multiple overloads of 'address' instantiate to the same signature

My problem is i am developping a cli software on a mac and the final binary will execute on a linux system.
So i use a docker to compile but i have an error that doesn't seem to come from my code (since it works like a charm on mac) but you know ...
I don't have enought background in cpp / tool chain to understand what cause this error on linux and what to do to solve this issue.
TLDR :
cpp_1 | [ 8%] Building CXX object core-lib/CMakeFiles/core-lib.dir/controllers/MainController.cpp.o
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/controllers/MainController.cpp:8:
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/controllers/MainController.hpp:11:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/vector:61:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/allocator.h:46:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0/bits/c++allocator.h:33:
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:93:7: error: multiple overloads of 'address' instantiate to the same signature '__gnu_cxx::new_allocator<const ColumnState>::const_pointer (__gnu_cxx::new_allocator<const ColumnState>::const_reference) const noexcept' (aka 'const ColumnState *(const ColumnState &) const noexcept')
cpp_1 | address(const_reference __x) const _GLIBCXX_NOEXCEPT
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/allocator.h:108:29: note: in instantiation of template class '__gnu_cxx::new_allocator<const ColumnState>' requested here
cpp_1 | class allocator: public __allocator_base<_Tp>
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:550:16: note: in instantiation of template class 'std::allocator<const ColumnState>' requested here
cpp_1 | : public _Tp_alloc_type
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:633:19: note: in instantiation of member class 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >::_Deque_impl' requested here
cpp_1 | _Deque_impl _M_impl;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:831:29: note: in instantiation of template class 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >' requested here
cpp_1 | class deque : protected _Deque_base<_Tp, _Alloc>
cpp_1 | ^
cpp_1 | /usr/src/OF/apps/project/core-lib/io/AbstractInstallCommunicator.hpp:17:35: note: in instantiation of template class 'std::deque<const ColumnState, std::allocator<const ColumnState> >' requested here
cpp_1 | std::deque<const ColumnState> states;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:89:7: note: previous declaration is here
cpp_1 | address(reference __x) const _GLIBCXX_NOEXCEPT
the CMAKE cpp config :
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
linux config :
ubuntu bionic
cmake --version : cmake version 3.16.5
make --version : GNU Make 4.1
clang --version : clang version 10.0.0-4ubuntu1~18.04.1
mac config
Mojave 10.14.6
cmake --version : cmake version 3.16.3
make --version : GNU Make 3.81
clang --version : Apple clang version 11.0.0 (clang-1100.0.33.17)
When I compile on mac it works fine :
building
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GLM: /usr/local/include
-- GLM_INCLUDE_DIR = /usr/local/include
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/fyoudine/Documents/workspaces/OF/of_v20190923_osx_release/apps/project-Optics/build
Scanning dependencies of target core-lib
[ 2%] Building CXX object core-lib/CMakeFiles/core-lib.dir/config/GlobalConf.cpp.o
[ 5%] Building CXX object core-lib/CMakeFiles/core-lib.dir/controllers/LightManager.cpp.o
[ 8%] Building CXX object core-lib/CMakeFiles/core-lib.dir/controllers/MainController.cpp.o
[ 11%] Building CXX object core-lib/CMakeFiles/core-lib.dir/d3/Object3D.cpp.o
[ 14%] Building CXX object core-lib/CMakeFiles/core-lib.dir/d3/Object3DChild.cpp.o
[ 17%] Building CXX object core-lib/CMakeFiles/core-lib.dir/install/AbstractInstall.cpp.o
[ 20%] Building CXX object core-lib/CMakeFiles/core-lib.dir/install/FileConfigurationInstall.cpp.o
[ 22%] Building CXX object core-lib/CMakeFiles/core-lib.dir/install/KineticInstall.cpp.o
[ 25%] Building CXX object core-lib/CMakeFiles/core-lib.dir/io/DMXCommunicator.cpp.o
[ 28%] Building CXX object core-lib/CMakeFiles/core-lib.dir/io/SimulatorInstallCommunicator.cpp.o
[ 31%] Building CXX object core-lib/CMakeFiles/core-lib.dir/positions/PositionSummaryMap.cpp.o
[ 34%] Building CXX object core-lib/CMakeFiles/core-lib.dir/positions/SimpleOptimalPositionFinder.cpp.o
[ 37%] Building CXX object core-lib/CMakeFiles/core-lib.dir/provider/SimpleAnimationProvider.cpp.o
[ 40%] Building CXX object core-lib/CMakeFiles/core-lib.dir/raytracing/Prism.cpp.o
[ 42%] Building CXX object core-lib/CMakeFiles/core-lib.dir/raytracing/Ray/AABB.cpp.o
[ 45%] Building CXX object core-lib/CMakeFiles/core-lib.dir/raytracing/Ray/Base.cpp.o
[ 48%] Building CXX object core-lib/CMakeFiles/core-lib.dir/raytracing/Ray/Plane.cpp.o
[ 51%] Building CXX object core-lib/CMakeFiles/core-lib.dir/raytracing/Ray/Ray.cpp.o
[ 54%] Building CXX object core-lib/CMakeFiles/core-lib.dir/raytracing/RayPath.cpp.o
[ 57%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/Environment.cpp.o
[ 60%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/Simulator.cpp.o
[ 62%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/anim/InstallAnimator.cpp.o
[ 65%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/anim/TweenColumnAnimator.cpp.o
[ 68%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/data/RayCastResult.cpp.o
[ 71%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/elements/ColumnData.cpp.o
[ 74%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/elements/Light.cpp.o
[ 77%] Building CXX object core-lib/CMakeFiles/core-lib.dir/simulation/elements/PrismData.cpp.o
[ 80%] Building CXX object core-lib/CMakeFiles/core-lib.dir/states/ColumnState.cpp.o
[ 82%] Building CXX object core-lib/CMakeFiles/core-lib.dir/states/InstallState.cpp.o
[ 85%] Building CXX object core-lib/CMakeFiles/core-lib.dir/utils/calculateSunPosition.cpp.o
[ 88%] Building CXX object core-lib/CMakeFiles/core-lib.dir/utils/spa.cpp.o
[ 91%] Building CXX object core-lib/CMakeFiles/core-lib.dir/utils/vec_color.cpp.o
[ 94%] Linking CXX static library ../libs/libcore-lib.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../libs/libcore-lib.a(InstallAnimator.cpp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../libs/libcore-lib.a(InstallAnimator.cpp.o) has no symbols
[ 94%] Built target core-lib
Scanning dependencies of target project-cli
[ 97%] Building CXX object project-cli/CMakeFiles/project-cli.dir/main.cpp.o
[100%] Linking CXX executable ../../bin/project-cli
[100%] Built target project-cli
But when I compile for linux via docker :
starting docker_cpp_1 ... done
Attaching to docker_cpp_1
cpp_1 | building
cpp_1 | -- The C compiler identification is Clang 10.0.0
cpp_1 | -- The CXX compiler identification is Clang 10.0.0
cpp_1 | -- Check for working C compiler: /usr/bin/clang-10
cpp_1 | -- Check for working C compiler: /usr/bin/clang-10 -- works
cpp_1 | -- Detecting C compiler ABI info
cpp_1 | -- Detecting C compiler ABI info - done
cpp_1 | -- Detecting C compile features
cpp_1 | -- Detecting C compile features - done
cpp_1 | -- Check for working CXX compiler: /usr/bin/clang++-10
cpp_1 | -- Check for working CXX compiler: /usr/bin/clang++-10 -- works
cpp_1 | -- Detecting CXX compiler ABI info
cpp_1 | -- Detecting CXX compiler ABI info - done
cpp_1 | -- Detecting CXX compile features
cpp_1 | -- Detecting CXX compile features - done
cpp_1 | -- Found GLM: /usr/include
cpp_1 | -- GLM_INCLUDE_DIR = /usr/include
cpp_1 | -- Configuring done
cpp_1 | -- Generating done
cpp_1 | -- Build files have been written to: /usr/src/OF/apps/project/build
cpp_1 | Scanning dependencies of target core-lib
cpp_1 | [ 2%] Building CXX object core-lib/CMakeFiles/core-lib.dir/config/GlobalConf.cpp.o
cpp_1 | [ 5%] Building CXX object core-lib/CMakeFiles/core-lib.dir/controllers/LightManager.cpp.o
cpp_1 | [ 8%] Building CXX object core-lib/CMakeFiles/core-lib.dir/controllers/MainController.cpp.o
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/controllers/MainController.cpp:8:
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/controllers/MainController.hpp:11:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/vector:61:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/allocator.h:46:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0/bits/c++allocator.h:33:
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:93:7: error: multiple overloads of 'address' instantiate to the same signature '__gnu_cxx::new_allocator<const ColumnState>::const_pointer (__gnu_cxx::new_allocator<const ColumnState>::const_reference) const noexcept' (aka 'const ColumnState *(const ColumnState &) const noexcept')
cpp_1 | address(const_reference __x) const _GLIBCXX_NOEXCEPT
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/allocator.h:108:29: note: in instantiation of template class '__gnu_cxx::new_allocator<const ColumnState>' requested here
cpp_1 | class allocator: public __allocator_base<_Tp>
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:550:16: note: in instantiation of template class 'std::allocator<const ColumnState>' requested here
cpp_1 | : public _Tp_alloc_type
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:633:19: note: in instantiation of member class 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >::_Deque_impl' requested here
cpp_1 | _Deque_impl _M_impl;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:831:29: note: in instantiation of template class 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >' requested here
cpp_1 | class deque : protected _Deque_base<_Tp, _Alloc>
cpp_1 | ^
cpp_1 | /usr/src/OF/apps/project/core-lib/io/AbstractInstallCommunicator.hpp:17:35: note: in instantiation of template class 'std::deque<const ColumnState, std::allocator<const ColumnState> >' requested here
cpp_1 | std::deque<const ColumnState> states;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/ext/new_allocator.h:89:7: note: previous declaration is here
cpp_1 | address(reference __x) const _GLIBCXX_NOEXCEPT
cpp_1 | ^
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/controllers/MainController.cpp:8:
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/controllers/MainController.hpp:16:
cpp_1 | In file included from /usr/src/OF/apps/project/core-lib/install/AbstractInstall.hpp:11:
cpp_1 | In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/deque:64:
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:843:31: error: '_Tp_alloc_type' is a protected member of 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >'
cpp_1 | typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
cpp_1 | ^
cpp_1 | /usr/src/OF/apps/project/core-lib/io/AbstractInstallCommunicator.hpp:17:35: note: in instantiation of template class 'std::deque<const ColumnState, std::allocator<const ColumnState> >' requested here
cpp_1 | std::deque<const ColumnState> states;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:464:21: note: declared protected here
cpp_1 | rebind<_Tp>::other _Tp_alloc_type;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:844:31: error: '_Alloc_traits' is a protected member of 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >'
cpp_1 | typedef typename _Base::_Alloc_traits _Alloc_traits;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:465:58: note: declared protected here
cpp_1 | typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:845:31: error: '_Map_pointer' is a protected member of 'std::_Deque_base<const ColumnState, std::allocator<const ColumnState> >'
cpp_1 | typedef typename _Base::_Map_pointer _Map_pointer;
cpp_1 | ^
cpp_1 | /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_deque.h:544:47: note: declared protected here
cpp_1 | typedef typename iterator::_Map_pointer _Map_pointer;
cpp_1 | ^
cpp_1 | 4 errors generated.
cpp_1 | make[2]: *** [core-lib/CMakeFiles/core-lib.dir/controllers/MainController.cpp.o] Error 1
cpp_1 | core-lib/CMakeFiles/core-lib.dir/build.make:88: recipe for target 'core-lib/CMakeFiles/core-lib.dir/controllers/MainController.cpp.o' failed
cpp_1 | make[1]: *** [core-lib/CMakeFiles/core-lib.dir/all] Error 2
cpp_1 | CMakeFiles/Makefile2:114: recipe for target 'core-lib/CMakeFiles/core-lib.dir/all' failed
cpp_1 | make: *** [all] Error 2
cpp_1 | Makefile:83: recipe for target 'all' failed
docker_cpp_1 exited with code 2
both are compiled with the same command :
cmake .. && make
The error itself comes from the definition of std::deque<const ColumnState> states. Until C+11 the element types of std::deque had to be CopyAssignable and CopyConstructible (thus can't be const qualified as in you code) - see std::deque.
After C+11 the constraints are actually imposed by the operations done on the deque:
The requirements that are imposed on the elements depend on the actual operations performed on the container. Generally, it is required that element type is a complete type and meets the requirements of Erasable, but many member functions impose stricter requirements.
So without seeing the code that manipulates states it is hard to see what exactly triggers this. A trivial workaround (if the context allows it) is to remove the const there. Of course, both compilers should behave the same (if they both honor c++17 and there actually is an operation on the variable which violates the constness), but if you just need a quick fix this could do.

building opencv 2.4.6 on Mac - Mavericks

I downloaded opencv 2.4.6 for mac OSX (Mavericks). Untared the tar file and made the following steps:
cd opencv-2.4.6.1/
mkdir build
cd build/
cmake -G "Unix Makefiles" ..
make -j8
But I get an error on the build
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/core/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/imgproc/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(core)
^~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
CV_PERF_TEST_MAIN(imgproc)
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/highgui/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(highgui)
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
1 error generated.
1 error generated.
make[2]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [modules/highgui/CMakeFiles/opencv_perf_highgui.dir/perf/perf_main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
1 error generated.
make[2]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/all] Error 2
[ 50%] [ 50%] [ 50%] Building CXX object modules/highgui/CMakeFiles/opencv_perf_highgui.dir/perf/perf_precomp.cpp.o
Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_fast.cpp.o
Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_descriptors_regression.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_detectors_regression.cpp.o
[ 50%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_ffmpeg.cpp.o
[ 50%] Building CXX object modules/calib3d/CMakeFiles/opencv_perf_calib3d.dir/perf/perf_main.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_main.cpp.o
make[1]: *** [modules/highgui/CMakeFiles/opencv_perf_highgui.dir/all] Error 2
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_fast.cpp.o
[ 50%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_fourcc.cpp.o
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_orb.cpp.o
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/calib3d/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(calib3d)
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_keypoints.cpp.o
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/features2d/perf/perf_main.cpp:3:1: error:
multiple unsequenced modifications to 'argc' [-Werror,-Wunsequenced]
CV_PERF_TEST_MAIN(features2d)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:501:5: note:
expanded from macro 'CV_PERF_TEST_MAIN'
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobo/dir/opencv/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note:
expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS'
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construct...
^ ~~
1 error generated.
make[2]: *** [modules/calib3d/CMakeFiles/opencv_perf_calib3d.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/calib3d/CMakeFiles/opencv_perf_calib3d.dir/all] Error 2
[ 50%] Building CXX object modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_precomp.cpp.o
1 error generated.
make[2]: *** [modules/features2d/CMakeFiles/opencv_perf_features2d.dir/perf/perf_main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_framecount.cpp.o
[ 51%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_main.cpp.o
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_grfmt.cpp.o
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_gui.cpp.o
[ 51%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_matchers_algorithmic.cpp.o
[ 51%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_main.cpp.o
[ 51%] [ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_positioning.cpp.o
Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_mser.cpp.o
[ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_precomp.cpp.o
[ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_video_io.cpp.o
make[1]: *** [modules/features2d/CMakeFiles/opencv_perf_features2d.dir/all] Error 2
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_nearestneighbors.cpp.o
[ 52%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_video_pos.cpp.o
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_orb.cpp.o
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_precomp.cpp.o
[ 52%] Building CXX object modules/features2d/CMakeFiles/opencv_test_features2d.dir/test/test_rotation_and_scale_invariance.cpp.o
Linking CXX executable ../../bin/opencv_test_highgui
[ 52%] Built target opencv_test_highgui
Linking CXX executable ../../bin/opencv_test_features2d
[ 52%] Built target opencv_test_features2d
make: *** [all] Error 2
I used this compilation options for cmake:
cmake -G "Unix Makefiles" -D CMAKE_INSTALL_PREFIX=/Users/produit/Library/Developer/opencv/ -D CMAKE_OSX_ARCHITECTURES=x86_64 -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_legacy=NO ..
It's strange, the bug hase already been reported! http://code.opencv.org/issues/3179
And have already been solved:
https://github.com/Itseez/opencv/pull/1244
Still - for a quick solution:
Open up the
[...]opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp
Edit around line 480:
with the following:
#if defined(_MSC_VER) && (_MSC_VER <= 1400)
#define CV_PERF_TEST_MAIN_INTERNALS_ARGS(...) \
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/
#else
#define CV_PERF_TEST_MAIN_INTERNALS_ARGS(...) \
__VA_ARGS__;
#endif
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
CV_PERF_TEST_MAIN_INTERNALS_ARGS(__VA_ARGS__) \'
instead of:
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\
Its more or less this change on git:
https://github.com/vkocheganov/opencv/commit/e4b201be25ff92e930b979098e94a89368677313
Worked for me :-)