'dummy' may be used uninitialized - c++

I have an issue running a clion project stepik file. The following error keeps showing up. I have a compiler and I can run other codes, but some doesn't work.
In file included from /home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-all.cc:42:
/home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-death-test.cc:1224:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
1224 | StackLowerThanAddress(&dummy, &result);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-death-test.cc:1214:13: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
1214 | static void StackLowerThanAddress(const void* ptr, bool* result) {
| ^~~~~~~~~~~~~~~~~~~~~
/home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-death-test.cc:1222:7: note: ‘dummy’ declared here
1222 | int dummy;
| ^~~~~
cc1plus: all warnings being treated as errors
gmake[3]: *** [../test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/build.make:72: ../test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:587: ../test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:1394: lesson1/labbeli/CMakeFiles/global-lesson1-labbeli-test.dir/rule] Error 2
gmake: *** [Makefile:598: global-lesson1-labbeli-test] Error 2

This problem is not in your own project, but in a library it seems to be using: GoogleTest.
The version of GoogleTest you're using currently has a problem when compiled with GCC 11. GCC gives off this warning (for various complex reasons). GoogleTest has configured that any warnings the compiler gives should be treated as errors. And so GCC will stop compiling when it encounters that warning.
It's not your mistake, but up to GoogleTest to fix. A fix has been made and merged here: https://github.com/google/googletest/pull/3024
Updating GoogleTest to use version 1.11.0 or newer should resolve the problem.

Related

CMake ignoring compilation flags [duplicate]

This question already has answers here:
Passing compiler options in CMake
(6 answers)
Closed 10 months ago.
I'm trying to compile assimp using MinGW.
I run the commands
cmake CMakeLists.txt -G "MinGW Makefiles" -Wno-error
cmake --build .
but when the project builds I still get an error and the build fails.
The error:
In file included from C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.c:22:
C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.c: In function 'ftell64_file_func':
C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.h:39:21: error: implicit declaration of function 'ftello'; did you mean 'ftell'? [-Werror=implicit-function-declaration]
39 | # define ftello64 ftello
| ^~~~~~
C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.c:245:11: note: in expansion of macro 'ftello64'
245 | ret = ftello64(ioposix->file);
| ^~~~~~~~
C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.c: In function 'fseek64_file_func':
C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.h:40:21: error: implicit declaration of function 'fseeko'; did you mean 'fseek'? [-Werror=implicit-function-declaration]
40 | # define fseeko64 fseeko
| ^~~~~~
C:\godijustwantittowork\include\assimp-5.2.3\contrib\unzip\ioapi.c:303:9: note: in expansion of macro 'fseeko64'
303 | if (fseeko64(ioposix->file, offset, fseek_origin) != 0)
| ^~~~~~~~
cc1.exe: all warnings being treated as errors
code\CMakeFiles\assimp.dir\build.make:3049: recipe for target 'code/CMakeFiles/assimp.dir/__/contrib/unzip/ioapi.c.obj' failed
mingw32-make.exe[2]: *** [code/CMakeFiles/assimp.dir/__/contrib/unzip/ioapi.c.obj] Error 1
CMakeFiles\Makefile2:249: recipe for target 'code/CMakeFiles/assimp.dir/all' failed
mingw32-make.exe[1]: *** [code/CMakeFiles/assimp.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
Couldn't find an answer on here so sorry if this is a duplicate.
Passing -Wno-error to cmake doesn't magically cause CMake to pass that flag to any and all compilers for any and all languages.
To pass a flag to the C compiler, put CFLAGS=-Wno-error on your CMake command line. See e.g. this answer. You may need to clear your CMake cache.
Also note that this is unlikely to help you, because suppressing the implicit declaration warning still doesn't make those ftello and fseeko functions available.

How do I start to debug “recipe for target 'all' failed” When compiling a C ++ Library

Any tips on where I can start bugging this would be great.
I'm not sure where to start
I'm building this Library Unmodified using CMake and MinGW,
I'm getting a series of warnings about deprecated code being used but as I haven't developed this code I don't know about modifying it to remove those, and since they're warnings not errors I'm not sure if this is necessary.
C:\Users\user\Desktop\ccfits3\CCfits\FITS.cxx: In constructor 'CCfits::FITS::FITS(const String&, CCfits::RWmode, bool, const std::vector<std::__cxx11::basic_string<char> >&)':
C:\Users\user\Desktop\ccfits3\CCfits\FITS.cxx:91:11: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr<FITSBase> apBase(new FITSBase(name,mode));
^~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_conv.h:41:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\locale:43,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iomanip:43,
from C:\Users\user\Desktop\ccfits3\CCfits\KeyData.h:20,
from C:\Users\user\Desktop\ccfits3\CCfits\KeywordCreator.h:13,
from C:\Users\user\Desktop\ccfits3\CCfits\NewKeyword.h:13,
from C:\Users\user\Desktop\ccfits3\CCfits\HDU.h:21,
from C:\Users\user\Desktop\ccfits3\CCfits\ExtHDU.h:15,
from C:\Users\user\Desktop\ccfits3\CCfits\Table.h:13,
from C:\Users\user\Desktop\ccfits3\CCfits\FITS.cxx:10:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\unique_ptr.h:49:28: note: declared here
template<typename> class auto_ptr;
^~~~~~~~
C:\Users\user\Desktop\ccfits3\CCfits\FITS.cxx: In constructor 'CCfits::FITS::FITS(const String&, CCfits::RWmode, const string&, bool, const std::vector<std::__cxx11::basic_string<char> >&, const std::vector<std::__cxx11::basic_string<char> >&, int)':
C:\Users\user\Desktop\ccfits3\CCfits\FITS.cxx:147:16: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
std::auto_ptr<FITSBase> apBase(new FITSBase(name,mode));
^~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_conv.h:41:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\locale:43,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iomanip:43,
from C:\Users\user\Desktop\ccfits3\CCfits\KeyData.h:20,
from C:\Users\user\Desktop\ccfits3\CCfits\KeywordCreator.h:13,
from C:\Users\user\Desktop\ccfits3\CCfits\NewKeyword.h:13,
from C:\Users\user\Desktop\ccfits3\CCfits\HDU.h:21,
from C:\Users\user\Desktop\ccfits3\CCfits\ExtHDU.h:15,
from C:\Users\user\Desktop\ccfits3\CCfits\Table.h:13,
from C:\Users\user\Desktop\ccfits3\CCfits\FITS.cxx:10:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\unique_ptr.h:49:28: note: declared here
template<typename> class auto_ptr;
^~~~~~~~
at the end of the build process, I get the error
"C:\Program Files\JetBrains\CLion 2020.2.4\bin\cmake\win\bin\cmake.exe" --build
C:\Users\user\Desktop\cfits2\CCfits\debug --target all -- -j 3
mingw32-make.exe[2]: *** [libCCfits.a] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/CCfits.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
CMakeFiles\CCfits.dir\build.make:375: recipe for target 'libCCfits.a' failed
CMakeFiles\Makefile2:96: recipe for target 'CMakeFiles/CCfits.dir/all' failed
Makefile:159: recipe for target 'all' failed
I don't know where to go from here what's my next step in the still bugging process.
the error really doesn't seem to tell me anything useful, and the warnings are probably unrelated I think.
I don't think I can get rid of the warnings without a deeper understanding of the library.
thank you please forgive the stupid question

How to get the emgucv compiled on my Ubuntu 18.04? It is said to support Ubuntu

First I am not very familiar with C++ compile process, but I have to compile the emgucv repository on Ubuntu 18.04. I follow the instruction and try to figure out things by searching through Stack Exchange.
I got every dependencies setup, then the only file I need to execute is this one.
Although it is written for 16.04, seems to work for 18.04, but the compilation throws an error. It says _MAX_DRIVE, _MAX_DIR, _MAX_PATH, DWORD, errno_t, etc. are not declared. As suggested by the comment, they are Windows-specific. The error occurs in this file. And the module that contains this file is this.
My question is how to get this compiled on Ubuntu 18.04? I am very confused, since Emgucv says they support Linux (instruction at the end), and I believe others could have successfully compiled it on their Linux. I attempted to replace those constants _MAX_DRIVE, _MAX_DIR, _MAX_PATH by just numbers, the DWORD by unsigned long, and errno_t by int, then it says now GetModuleFileName, _splitpath_s are not declared. I don't know how to do. Is there anyway for this to work for Ubuntu?
[ 74%] Building CXX object Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp: In member function ‘void tesseract::CCUtil::main_setup(const char*, const char*)’:
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:77:16: error: ‘_MAX_DRIVE’ was not declared in this scope
char drive[_MAX_DRIVE];
^~~~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:78:14: error: ‘_MAX_DIR’ was not declared in this scope
char dir[_MAX_DIR];
^~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:79:15: error: ‘_MAX_PATH’ was not declared in this scope
char path[_MAX_PATH];
^~~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:83:5: error: ‘DWORD’ was not declared in this scope
DWORD length = GetModuleFileName(nullptr, path, sizeof(path));
^~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:85:9: error: ‘length’ was not declared in this scope
if (length > 0 && length < sizeof(path)) {
^~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:85:39: error: ‘path’ was not declared in this scope
if (length > 0 && length < sizeof(path)) {
^~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:86:7: error: ‘errno_t’ was not declared in this scope
errno_t result = _splitpath_s(path, drive, sizeof(drive),
^~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:88:11: error: ‘result’ was not declared in this scope
if (result == ERANGE) {
^~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:92:17: error: ‘drive’ was not declared in this scope
datadir = drive;
^~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:93:18: error: ‘dir’ was not declared in this scope
datadir += dir;
^~~
Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/build.make:302: recipe for target 'Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o' failed
make[2]: *** [Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o] Error 1
CMakeFiles/Makefile2:5929: recipe for target 'Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/all' failed
make[1]: *** [Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Emgu CV compile manual for Ubuntu
The commands are summarized below
git clone https://github.com/emgucv/emgucv emgucv
cd emgucv
git submodule update --init --recursive
cd platforms/ubuntu/16.04
./apt_install_dependency.sh
./cmake_configure.sh

Fail to compile library - openalpr

I'm trying to install openalpr on MacOSX El Capitan 10.11.6
and when I tried to run 'make' command, it goes smoothly until it reaches 55% which it generates following errors. Here are the steps that I followed (https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(OS-X))
error output image
The remaining outputs are:
In file included from /Users/Anonymous/openalpr/src/daemon.cpp:8:
In file included from
/Users/Anonymous/openalpr/src/video/logging_videobuffer.h:5:
In file included from /usr/local/include/log4cplus/logger.h:36:
In file included from
/usr/local/include/log4cplus/spi/appenderattachable.h:33:
In file included from /usr/local/include/log4cplus/appender.h:36:
/usr/local/include/log4cplus/helpers/pointer.h:134:21: error: cannot
initialize object parameter of type 'const
log4cplus::helpers::SharedObject' with an expression of type
'log4cplus::spi::Filter'
pointee->removeReference();
^~~~~~~
/usr/local/include/log4cplus/helpers/pointer.h:152:17: note: in
instantiation of member function
'log4cplus::helpers::SharedObjectPtr<log4cplus::spi::Filter>::~SharedObjectPtr' requested here
SharedObjectPtr<T> (rhs).swap (*this);
^
/usr/local/include/log4cplus/helpers/pointer.h:147:30: note: in instantiation of member function 'log4cplus::helpers::SharedObjectPtr<log4cplus::spi::Filter>::operator=' requested here
return this->operator = (rhs.pointee);
^
/usr/local/include/log4cplus/appender.h:211:62: note: in instantiation of member function
'log4cplus::helpers::SharedObjectPtr<log4cplus::spi::Filter>::operator=' requested here
void setFilter(log4cplus::spi::FilterPtr f) { filter = f; }
^
1 warning and 7 errors generated.
make[2]: *** [CMakeFiles/alprd.dir/daemon.cpp.o] Error 1
make[1]: *** [CMakeFiles/alprd.dir/all] Error 2
make: *** [all] Error 2`
I believe you're missing the atomic library. You can find it here. Place it alongside all the other c++ include files in your system.

upgrade gcc + compiling ROOT

I am working on ROOT v6.06.06 on ubuntu 14.04. Everything went OK.
Lately i did apt-get upgrade, and this affected the c++ compiler.
Since then, when i try to run my macros on ROOT, I have this error:
fatal error: file '/usr/include/c++/4.9/cmath' modified since it was first processed
I tried then to re-compile ROOT, but it's not working, I have this error:
[ 36%] Building CXX object interpreter/llvm/src/tools/clang/lib/Driver/CMakeFiles/clangDriver.dir/ToolChains.cpp.o
.../root/interpreter/llvm/src/tools/clang/lib/Driver/ToolChains.cpp: In static member function ‘static std::string clang::driver::toolchains::Hexagon_TC::GetGnuDir(const string&, const llvm::opt::ArgList&)’:
.../root/root6/root/interpreter/llvm/src/tools/clang/lib/Driver/ToolChains.cpp:2110:42: error: ‘LLVM_PREFIX’ was not declared in this scope
std::string PrefixRelDir = std::string(LLVM_PREFIX) + "/../gnu";
^
make[2]: *** [interpreter/llvm/src/tools/clang/lib/Driver/CMakeFiles/clangDriver.dir/ToolChains.cpp.o] Error 1
make[1]: *** [interpreter/llvm/src/tools/clang/lib/Driver/CMakeFiles/clangDriver.dir/all] Error 2
make: *** [all] Error 2
So I need either solving the c++ compiler so i can use the last compiled version of ROOT that I have,
Or succeed to solve the problem while compiling ROOT.
Can you help me please? I am blocked. Thanks a lot.