Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22225

How to compile cmake Werror project with a newer compiler?

$
0
0

I am trying to build an old version of opencv (https://github.com/opencv/opencv/archive/3.4.16.zip). The repo uses -Werror=all or something. On my computer with Ubuntu 22.04 with gcc 11.4, cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..; make works. On my other computer with Ubuntu 24.04 and gcc 13.3 the build fails

[ 29%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/persistence_types.cpp.o/home/josh/Downloads/opencv-3.4.16/modules/core/src/persistence_base64.cpp: In function ‘bool base64::base64_valid(const uint8_t*, size_t, size_t)’:/home/josh/Downloads/opencv-3.4.16/modules/core/src/persistence_base64.cpp:167:31: error: comparing the result of pointer addition ‘(src + ((sizetype)off))’ and NULL [-Werror=address]  167 |     if (src == 0 || src + off == 0)      |                     ~~~~~~~~~~^~~~cc1plus: some warnings being treated as errorsmake[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:971: modules/core/CMakeFiles/opencv_core.dir/src/persistence_base64.cpp.o] Error 1

I tried passing -DCMAKE_CXX_FLAGS:

cmake  -D CMAKE_INSTALL_PREFIX=/usr/local .. -DCMAKE_CXX_FLAGS="-Wno-all -Wno-address"

But this doesn't bypass the error.

Without maintaining a fork with a modified cmake file, how can I build an old project that treats warnings as errors with a newer compiler with more warnings?


Aside: After posting the question, I tried hacking at the cmake to just get past this for now, but newer versions of other dependencies are also causing the build to fail. The general question stands though.

Also if you're trying to build opencv yourself, I ran out of memory running make -j. Limit it to like make -j4


Viewing all articles
Browse latest Browse all 22225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>