I'm trying to install OpenCV on my Windows, using cygwin, using these commands :
cd ~
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 2.4.5
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make -j8
sudo make install
The Problem is after i try to use command: "make -j8" , i get this error at around 67% :
[ 67%] Building CXX object modules/legacy/CMakeFiles/opencv_legacy.dir/src/calibfilter.cpp.o
/cygdrive/d/newbuild/opencv/modules/legacy/src/calibfilter.cpp: In member function ‘virtual bool CvCalibFilter::SaveCameraParams(const char*)’:
/cygdrive/d/newbuild/opencv/modules/legacy/src/calibfilter.cpp:689:47: error: ‘CvStereoCamera {aka struct CvStereoCamera}’ has no member named ‘quad’
fprintf(f, "%15.10f ", stereo.quad[i][j].x );
^
/cygdrive/d/newbuild/opencv/modules/legacy/src/calibfilter.cpp:690:47: error: ‘CvStereoCamera {aka struct CvStereoCamera}’ has no member named ‘quad’
fprintf(f, "%15.10f ", stereo.quad[i][j].y );
^
/cygdrive/d/newbuild/opencv/modules/legacy/src/calibfilter.cpp: In member function ‘virtual bool CvCalibFilter::LoadCameraParams(const char*)’:
/cygdrive/d/newbuild/opencv/modules/legacy/src/calibfilter.cpp:746:57: error: ‘CvStereoCamera {aka struct CvStereoCamera}’ has no member named ‘quad’
int values_read = fscanf(f, "%f ", &(stereo.quad[i][j].x) );
^
/cygdrive/d/newbuild/opencv/modules/legacy/src/calibfilter.cpp:748:53: error: ‘CvStereoCamera {aka struct CvStereoCamera}’ has no member named ‘quad’
values_read = fscanf(f, "%f ", &(stereo.quad[i][j].y) );
^
make[2]: *** [modules/legacy/CMakeFiles/opencv_legacy.dir/build.make:639: modules/legacy/CMakeFiles/opencv_legacy.dir/src/calibfilter.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4703: modules/legacy/CMakeFiles/opencv_legacy.dir/all] Error 2
make: *** [Makefile:128: all] Error 2
How do I solve this problem? I already tried using "make" instead of "make -j"
there is no difference
EDIT: I want to use the specific 2.4.5 version of OpenCV
Related
I am trying to compile insight from source (git://sourceware.org/git/insight.git) on mingw64 (x86_64-w64-mingw32-gcc).
These are my ./configure options:
./configure --prefix=/opt/arm-none-eabi-insight --target=arm-none-eabi --disable-binutils --disable-elfcpp --disable-gas --disable-gold --disable-gprof --disable-ld --disable-rpath --disable-zlib --enable-sim --with-expat --with-python --without-libunwind --with-tcl=/mingw64/lib --with-tk=/mingw64/lib
make output error:
[...]
CXX gdbtk/generic/gdbtk-bp.o
CXX gdbtk/generic/gdbtk-cmds.o
gdbtk/generic/gdbtk-cmds.c: In function 'int gdb_listfiles(ClientData, Tcl_Interp*, int, Tcl_Obj* const*)':
gdbtk/generic/gdbtk-cmds.c:1213:25: error: cannot convert 'listfiles_info' to 'void (*)(const char*, const char*, void*)'
1213 | map_symbol_filenames (info, false);
| ^~~~
| |
| listfiles_info
In file included from gdbtk/generic/gdbtk-cmds.c:33:
./symfile.h:546:51: note: initializing argument 1 of 'void map_symbol_filenames(void (*)(const char*, const char*, void*), void*, int)'
546 | void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~
make[3]: *** [Makefile:1629: gdbtk/generic/gdbtk-cmds.o] Error 1
make[3]: Leaving directory '/d/Work/FC/build_insight/insight/bundle/gdb'
make[2]: *** [Makefile:10110: all-gdb] Error 2
make[2]: Leaving directory '/d/Work/FC/build_insight/insight/bundle'
make[1]: *** [Makefile:866: all] Error 2
make[1]: Leaving directory '/d/Work/FC/build_insight/insight/bundle'
make: *** [Makefile:4: notarget] Error 2
How can I disable the gtk component? I have tried ./configure with --disable-gtk but no success.
I'am trying to cross-compile the simplest DCMTK example I found and I can get it built.
I am running Ubuntu 18.04.4 LTS to cross compile using x86_64-w64-mingw32.
I have checked these answers and examples too, but they didn't work for me:
CMake: Cross-compiling linux-to-windows with MinGW does not find some system headers
https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/cross_compiling/Mingw
This is the only file of the project (main.cpp):
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
using namespace std;
int main()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("sample.dcm");
if (status.good())
{
OFString patientName;
if (fileformat.getDataset()->findAndGetOFString(DCM_PatientName, patientName).good())
{
cout << "Patient's Name: " << patientName << endl;
} else
cerr << "Error: cannot access Patient's Name!" << endl;
OFString patientID;
if (fileformat.getDataset()->findAndGetOFString(DCM_PatientID, patientID).good())
{
cout << "Patient's ID: " << patientID << endl;
} else
cerr << "Fatal Error: cannot access Patient's ID!" << endl;
} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
return 0;
}
This is my CMake.txt configuration file:
cmake_minimum_required(VERSION 2.8)
PROJECT(test1DCMTK)
add_executable(${PROJECT_NAME} "main.cpp")
SET(DCMTK_DIR /usr/local/include/dcmtk)
ADD_DEFINITIONS(-D_REENTRANT)
INCLUDE_DIRECTORIES(${DCMTK_DIR}/include)
LINK_DIRECTORIES(${DCMTK_DIR}/lib)
TARGET_LINK_LIBRARIES(test1DCMTK ofstd dcmdata)
And I am using this toolchain file:
### CMAKE cross compile settings for Windows running from Ubuntu 18.04.4 LTS x86_x64 amd64 ###
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
SET(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
SET(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix)
#SET(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
# which compilers to use for C and C++
#SET(CMAKE_C_COMPILER x86_x64-mingw32-gcc)
#SET(CMAKE_CXX_COMPILER x86_x64-mingw32-g++)
###SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
# here is the target environment located
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/lib/gcc/${TOOLCHAIN_PREFIX}/7.3-posix)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
When I configure, with CMake, I get this:
The C compiler identification is GNU 7.3.0
The CXX compiler identification is GNU 7.3.0
Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc-posix
Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc-posix -- 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: /usr/bin/x86_64-w64-mingw32-g++-posix
Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++-posix -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
But when I try to build the code, this is what I get:
/home/yo/Projects/test1DCMTK/main.cpp:1:10: fatal error: dcmtk/config/osconfig.h: No existe el archivo o el directorio
#include "dcmtk/config/osconfig.h"
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/test1DCMTK.dir/build.make:63: fallo en las instrucciones para el objetivo 'CMakeFiles/test1DCMTK.dir/main.cpp.obj'
make[2]: *** [CMakeFiles/test1DCMTK.dir/main.cpp.obj] Error 1
CMakeFiles/Makefile2:67: fallo en las instrucciones para el objetivo 'CMakeFiles/test1DCMTK.dir/all'
make[1]: *** [CMakeFiles/test1DCMTK.dir/all] Error 2
Makefile:83: fallo en las instrucciones para el objetivo 'all'
make: *** [all] Error 2
However, the library exists:
(base) yo#MiPC:/usr/local/include/dcmtk/config$ ls /usr/local/include/dcmtk/config/os*
/usr/local/include/dcmtk/config/osconfig.h
So, what am I doing wrong? What should I do to get it working properly?
I tried the answer of #squareskittles, and I got this when tried to build:
(base) yo#MiPC:~/Projects/build-test1DCMTK-win32$ make all
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yo/Projects/build-test1DCMTK-win32
Scanning dependencies of target test1DCMTK
[ 50%] Building CXX object CMakeFiles/test1DCMTK.dir/main.cpp.obj
In file included from /usr/local/include/dcmtk/dcmdata/dcistrma.h:28:0,
from /usr/local/include/dcmtk/dcmdata/dctk.h:30,
from /home/elekta/Projects/QT/TUTOS-QT/test1DCMTK/main.cpp:2:
/usr/local/include/dcmtk/ofstd/offile.h:74:9: error: ‘fpos64_t’ does not name a type; did you mean ‘fpos_t’?
typedef fpos64_t offile_fpos_t;
^~~~~~~~
fpos_t
/usr/local/include/dcmtk/ofstd/offile.h:866:15: error: ‘offile_fpos_t’ has not been declared
int fgetpos(offile_fpos_t *pos)
^~~~~~~~~~~~~
/usr/local/include/dcmtk/ofstd/offile.h:886:15: error: ‘offile_fpos_t’ has not been declared
int fsetpos(offile_fpos_t *pos)
^~~~~~~~~~~~~
/usr/local/include/dcmtk/ofstd/offile.h: In member function ‘int OFFile::fseek(offile_off_t, int)’:
/usr/local/include/dcmtk/ofstd/offile.h:757:5: error: ‘offile_fpos_t’ was not declared in this scope
offile_fpos_t off2 = off;
^~~~~~~~~~~~~
/usr/local/include/dcmtk/ofstd/offile.h:757:5: note: suggested alternative: ‘offile_off_t’
offile_fpos_t off2 = off;
^~~~~~~~~~~~~
offile_off_t
/usr/local/include/dcmtk/ofstd/offile.h:792:9: error: ‘off2’ was not declared in this scope
off2 += buf.st_size;
^~~~
/usr/local/include/dcmtk/ofstd/offile.h:792:9: note: suggested alternative: ‘off’
off2 += buf.st_size;
^~~~
off
/usr/local/include/dcmtk/ofstd/offile.h:808:29: error: ‘off2’ was not declared in this scope
result = this->fsetpos(&off2);
^~~~
/usr/local/include/dcmtk/ofstd/offile.h:808:29: note: suggested alternative: ‘off’
result = this->fsetpos(&off2);
^~~~
off
/usr/local/include/dcmtk/ofstd/offile.h: In member function ‘offile_off_t OFFile::ftell()’:
/usr/local/include/dcmtk/ofstd/offile.h:837:5: error: ‘offile_fpos_t’ was not declared in this scope
offile_fpos_t pos;
^~~~~~~~~~~~~
/usr/local/include/dcmtk/ofstd/offile.h:837:5: note: suggested alternative: ‘offile_off_t’
offile_fpos_t pos;
^~~~~~~~~~~~~
offile_off_t
/usr/local/include/dcmtk/ofstd/offile.h:838:24: error: ‘pos’ was not declared in this scope
if (this->fgetpos(&pos) != 0)
^~~
/usr/local/include/dcmtk/ofstd/offile.h:838:24: note: suggested alternative: ‘pow’
if (this->fgetpos(&pos) != 0)
^~~
pow
/usr/local/include/dcmtk/ofstd/offile.h:843:12: error: ‘pos’ was not declared in this scope
return pos;
^~~
/usr/local/include/dcmtk/ofstd/offile.h:843:12: note: suggested alternative: ‘pow’
return pos;
^~~
pow
/usr/local/include/dcmtk/ofstd/offile.h: In member function ‘int OFFile::fgetpos(int*)’:
/usr/local/include/dcmtk/ofstd/offile.h:873:48: error: cannot convert ‘int*’ to ‘fpos_t* {aka long long int*}’ for argument ‘2’ to ‘int fgetpos(FILE*, fpos_t*)’
result = STDIO_NAMESPACE fgetpos(file_, pos);
^
/usr/local/include/dcmtk/ofstd/offile.h: In member function ‘int OFFile::fsetpos(int*)’:
/usr/local/include/dcmtk/ofstd/offile.h:893:48: error: cannot convert ‘int*’ to ‘const fpos_t* {aka const long long int*}’ for argument ‘2’ to ‘int fsetpos(FILE*, const fpos_t*)’
result = STDIO_NAMESPACE fsetpos(file_, pos);
^
CMakeFiles/test1DCMTK.dir/build.make:63: fallo en las instrucciones para el objetivo 'CMakeFiles/test1DCMTK.dir/main.cpp.obj'
make[2]: *** [CMakeFiles/test1DCMTK.dir/main.cpp.obj] Error 1
CMakeFiles/Makefile2:67: fallo en las instrucciones para el objetivo 'CMakeFiles/test1DCMTK.dir/all'
make[1]: *** [CMakeFiles/test1DCMTK.dir/all] Error 2
Makefile:83: fallo en las instrucciones para el objetivo 'all'
make: *** [all] Error 2
Your CMake is adding the dcmtk include directories like this:
SET(DCMTK_DIR /usr/local/include/dcmtk)
INCLUDE_DIRECTORIES(${DCMTK_DIR}/include)
which evaluates to this path:
/usr/local/include/dcmtk/include
Your main.cpp file then includes dcmtk/config/osconfig.h, which (combining the two paths) suggests the header is located here:
/usr/local/include/dcmtk/include/dcmtk/config/osconfig.h
This doesn't seem correct. Try including only /usr/local/include in your CMake file instead:
INCLUDE_DIRECTORIES(/usr/local/include)
As a side note, CMake provides a Find Module for the DCMTK, so it will attempt to find the library and set some variable for you. You could try something like this, but depending on your CMake version, you may have varying results:
cmake_minimum_required(VERSION 2.8)
PROJECT(test1DCMTK)
find_package(DCMTK REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
SET(DCMTK_DIR /usr/local/include/dcmtk)
ADD_DEFINITIONS(-D_REENTRANT)
# Use the INCLUDE_DIRS variable populated by the DCMTK find module.
INCLUDE_DIRECTORIES(${DCMTK_INCLUDE_DIRS})
# Use the LIBRARIES variable populated by the DCMTK find module.
TARGET_LINK_LIBRARIES(test1DCMTK ofstd ${DCMTK_LIBRARIES})
If this successfully finds DCMTK, the DCMTK_INCLUDE_DIRS will likely contain all necessary include directories for DCMTK, not only the include directory you have added manually. This may help resolve the compiler errors you are seeing.
Hi I'm trying to use opencv in my Node.js project so I decided to use opencv4nodejs. So I used brew to install cmake that is required to install mentioned module. But when I'm trying to install opencv4nodejs the following errors occurs:
...
...
...
Scanning dependencies of target opencv_text
[ 84%] Building CXX object modules/text/CMakeFiles/opencv_text.dir/src/erfilter.cpp.o
[ 84%] Building CXX object modules/tracking/CMakeFiles/opencv_tracking.dir/src/feature.cpp.o
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/include/tesseract/baseapi.h:26:
In file included from /usr/local/include/tesseract/apitypes.h:23:
/usr/local/include/tesseract/publictypes.h:33:1: error: unknown type name 'constexpr'
constexpr int kPointsPerInch = 72;
^
/usr/local/include/tesseract/publictypes.h:33:11: error: expected unqualified-id
constexpr int kPointsPerInch = 72;
^
/usr/local/include/tesseract/publictypes.h:38:1: error: unknown type name 'constexpr'
constexpr int kMinCredibleResolution = 70;
^
/usr/local/include/tesseract/publictypes.h:38:11: error: expected unqualified-id
constexpr int kMinCredibleResolution = 70;
^
/usr/local/include/tesseract/publictypes.h:40:1: error: unknown type name 'constexpr'
constexpr int kMaxCredibleResolution = 2400;
^
/usr/local/include/tesseract/publictypes.h:40:11: error: expected unqualified-id
constexpr int kMaxCredibleResolution = 2400;
^
/usr/local/include/tesseract/publictypes.h:45:1: error: unknown type name 'constexpr'
constexpr int kResolutionEstimationFactor = 10;
^
/usr/local/include/tesseract/publictypes.h:45:11: error: expected unqualified-id
constexpr int kResolutionEstimationFactor = 10;
^
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/include/tesseract/baseapi.h:30:
In file included from /usr/local/include/tesseract/resultiterator.h:27:
In file included from /usr/local/include/tesseract/ltrresultiterator.h:27:
/usr/local/include/tesseract/unichar.h:171:8: error: function definition does not declare parameters
char chars[UNICHAR_LEN]{};
^
/usr/local/include/tesseract/unichar.h:60:12: error: use of undeclared identifier 'chars'
memset(chars, 0, UNICHAR_LEN);
^
/usr/local/include/tesseract/unichar.h:78:15: error: use of undeclared identifier 'chars'
int len = chars[UNICHAR_LEN - 1];
^
/usr/local/include/tesseract/unichar.h:84:12: error: use of undeclared identifier 'chars'
return chars;
^
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/include/tesseract/baseapi.h:30:
/usr/local/include/tesseract/resultiterator.h:103:63: error: a space is required between consecutive right angle brackets (use '> >')
virtual std::vector<std::vector<std::pair<const char*, float>>>*
^
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
In file included from /Users/iwanowicz/Documents/testApp/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/include/tesseract/baseapi.h:31:
/usr/local/include/tesseract/serialis.h:43:1: error: unknown type name 'constexpr'
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/include/tesseract/serialis.h:43:17: error: expected ';' at end of declaration
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/include/tesseract/serialis.h:43:18: error: C++ requires a type specifier for all declarations
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/include/tesseract/serialis.h:43:26: error: use of undeclared identifier 'T'
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/include/tesseract/serialis.h:43:41: error: expected ';' after top level declarator
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/include/tesseract/serialis.h:55:40: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, char* data, size_t n = 1);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [modules/text/CMakeFiles/opencv_text.dir/src/erfilter.cpp.o] Error 1
make[1]: *** [modules/text/CMakeFiles/opencv_text.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 84%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/dls.cpp.o
ld: warning: building for macOS, but linking in object file (../../3rdparty/ippicv/ippicv_mac/icv/lib/intel64/libippicv.a(pscopye9as_l9.o)) built for
[ 89%] Built target opencv_calib3d
make: *** [all] Error 2
ERR! child process exited with code 2 (for more info, set '--loglevel silly')
npm WARN testapp#1.0.0 No description
npm WARN testapp#1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv-build#0.1.9 install: `node ./install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv-build#0.1.9 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/iwanowicz/.npm/_logs/2019-09-09T06_14_39_892Z-debug.log
As I understand there are some problems with building(?) opencv but I can`t find solutions for.
Could you help me finish the proces of installation opencv4nodejs?
opencv installation using mingw32-make command in windows 10 platform, then likely end up in getting the below error.
Windows version : 10
OpenCv:3.2.0
Please suggest me in installing.
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
critical_section_(new CRITICAL_SECTION) {
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8830:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8840:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8848:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8858:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8879:27: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
critical_section_ = new CRITICAL_SECTION;
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8880:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
modules\ts\CMakeFiles\opencv_ts.dir\build.make:237: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj' failed
mingw32-make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj] Error 1
CMakeFiles\Makefile2:5379: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/all' failed
mingw32-make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I also faced the same problem while trying to build OpenCV 3.2.0 using mingw32 on Windows10. I searched a bit to find a fix on Github for similar problem. It said the problem was:
MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two separate (equivalent) structs, instead of using typedef
So, you have to add another typedef GTEST_CRITICAL_SECTION for _CRITICAL_SECTION and _RTL_CRITICAL_SECTION and use this typedef for either case.
Here is what to do :
Edit "ts_gtest.h" which is inside "opencv\sources\modules\ts\include\opencv2\ts\"
Replace this line (probably line 723)
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
struct _RTL_CRITICAL_SECTION;
with
#if GTEST_OS_WINDOWS_MINGW
// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
// separate (equivalent) structs, instead of using typedef
typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#else
// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION
typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif
Replace this line (probably on line 3060 before your edit - line number would have changed as you modified first part)
_RTL_CRITICAL_SECTION* critical_section_;
with
GTEST_CRITICAL_SECTION* critical_section_;
These two changes should fix your above error.
It was fixed by using TDM-gcc mingw compiler.
I'm trying to install Cassandra cpp-driver in Ubuntu.
I've done the steps specified in DataStax C/C++ Driver for Apache Cassandra (Beta), but i keep getting the following compile error.
[ 1%] Building CXX object CMakeFiles/cassandra.dir/src/buffer_collection.cpp.o
In file included from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/session.hpp:29:0, from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/types.hpp:22, from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/buffer_collection.cpp:19:
/root/libraries/cass_cpp-driver/git2/cpp-driver/src/logger.hpp: In member function 'int cass::Logger::init()':
/root/libraries/cass_cpp-driver/git2/cpp-driver/src/logger.hpp:40:59: error: no matching function for call to 'cass::AsyncQueue<cass::MPMCQueue<cass::Logger::LogMessage*> >::init(uv_loop_t*, cass::Logger* const, void (&)(uv_async_t*, int))'
int init() { return log_queue_.init(loop(), this, on_log); }
^
/root/libraries/cass_cpp-driver/git2/cpp-driver/src/logger.hpp:40:59: note: candidate is:
In file included from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/event_thread.hpp:21:0,
from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/session.hpp:20,
from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/types.hpp:22,
from /root/libraries/cass_cpp-driver/git2/cpp-driver/src/buffer_collection.cpp:19:
/root/libraries/cass_cpp-driver/git2/cpp-driver/src/async_queue.hpp:34:7: note: int cass::AsyncQueue<Q>::init(uv_loop_t*, void*, uv_async_cb) [with Q = cass::MPMCQueue<cass::Logger::LogMessage*>; uv_loop_t = uv_loop_s; uv_async_cb = void (*)(uv_async_s*); uv_async_t = uv_async_s] <near match>
int init(uv_loop_t* loop, void* data, uv_async_cb async_cb) {
^
/root/libraries/cass_cpp-driver/git2/cpp-driver/src/async_queue.hpp:34:7: note: no known conversion for argument 3 from 'void(uv_async_t*, int) {aka void(uv_async_s*, int)}' to 'uv_async_cb {aka void (*)(uv_async_s*)}'
make[2]: *** [CMakeFiles/cassandra.dir/src/buffer_collection.cpp.o] Error 1
make[1]: *** [CMakeFiles/cassandra.dir/all] Error 2
make: *** [all] Error 2
I've already fixed this compile errors in Cassandra cpp-driver, by down-versioning libuv to version libuv-0.10, the compile errors will be gone.
It seems that the latest updates for libuv is not yet supported by Cassandra cpp-driver.