opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.39k stars 5.76k forks source link

Error: 'nullptr' was not declared in this scope, because of header file of Tesseract #1636

Open tlimkim opened 6 years ago

tlimkim commented 6 years ago
System information (version)
Detailed description

Hello.

When I build the OpenCV, there is a compile error: ‘nullptr’ was not declared in this scope (see below for details). I think there is a problem with 'tesseract' that is support c++11.

If anyone who has an idea, please help this problem.

Thanks.

/usr/local/include/tesseract/tesscallback.h: In member function 'virtual R _ConstTessMemberResultCallback_1_5<del, R, T, P1, A1, A2, A3, A4, A5>::Run(A1, A2, A3, A4, A5)':
/usr/local/include/tesseract/tesscallback.h:8369:17: error: 'nullptr' was not declared in this scope
       member_ = nullptr;
alalek commented 6 years ago

Try OpenCV's ENABLE_CXX11=ON CMake flag.

tlimkim commented 6 years ago

Thanks for replying.

I set CMake flag but it didn't work. Instead of doing that, I added a line of code that enable to compile c++11 in CMakeLists.txt

Steps to reproduce
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

When I added this line and compile the OpenCV, there was no problem while compiling the headerfile of Tesseract.

Can I make a pull request about this issue?

alalek commented 6 years ago

I set CMake flag but it didn't work.

Did you see this CMake output (without your patch)?

--   C/C++:
--     Built as dynamic libs?:      YES
--     C++11:                       YES                  <---------------------
--     C++ Compiler:                /usr/bin/c++  (ver 5.4.0)
tlimkim commented 6 years ago

I saw that CMake output which is C++11: YES but it didn't affect compiling the OpenCV with Tesseract header files.

So I thought that there is a problem.. because there is correct for CMake output on C++11 but it doesn't work for actual compiling.

alalek commented 6 years ago

Run make VERBOSE=1 and check passed compiler options (for -std=c++11).

alalek commented 6 years ago

BTW, Did you have enable precompiled headers?

3.4.0

There was an issue with PCH processing (CMake doesn't provide native PCH support). Check this commit: https://github.com/opencv/opencv/commit/2aa18ca3e93a1a32fec2c063010b72335ac795e9#diff-980653262620d7624fd21ad16af8796f (available in 3.4.1)

tlimkim commented 6 years ago

In my cmake PCH source code (forked from few days ago), there isn't the codes that above issue.

What is the difference between modify CMakeList.txt and above issue?