Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

ie_cpu_extension compilation errors in Linux due to -Werror

Eran_L_Intel
Employee
730 Views

I'm trying to use the CPU extension for basic samples (with 2019.3.379), and compilation works fine under Windows.

Under Linux, the first issue I run into is that I get:

../inference_engine/src/extension/ext_list.cpp:45:2: error: extra ';' [-Werror=pedantic]
 };
  ^
../inference_engine/src/extension/ext_list.cpp:59:2: error: extra ';' [-Werror=pedantic]
 };
  ^

These are both due to -Werror enabled. Looking at the .cmake:

# treating warnings as errors
if (WIN32)
    if (TREAT_WARNING_AS_ERROR)
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
    endif ()
    if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275 /wd4267") #disable some warnings
    endif()
else()
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()

Why is the Windows behavior dependent on TREAT_WARNING_AS_ERROR, but the non-Windows different?

-Eran

0 Kudos
5 Replies
HemanthKum_G_Intel
730 Views

Hi Eran,

I haven't seen this issue. May I know your OS, system details and command history to build and run the OpenVINO samples?

Note:

-Wpedantic or -pedantic flag will issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std option used.

Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few require -ansi or a -std option specifying the required version of ISO C). However, without this option, certain GNU extensions and traditional C and C++ features are supported as well. With this option, they are rejected.

0 Kudos
Eran_L_Intel
Employee
730 Views

Hi Kumar,

This is on an Intel NUC running Ubuntu 18.04.3 LTS, GNU 7.4.

The ie_cpu_extension is invoked from within another project, like this:

set(IE_ROOT_DIR "${INTEL_OPENVINO_DIR}/inference_engine")
include(${INTEL_OPENVINO_DIR}/inference_engine/share/InferenceEngineConfig.cmake)
target_link_libraries(<target> <other-dependencies...> ${InferenceEngine_LIBRARIES} ie_cpu_extension)

The parent project does use -pedantic, but -Werror comes from the inference_engine/src/extension/CMakeLists.txt I quoted above. The warning itself is warranted (the .cpp has semicolons that are NOT needed) and harmless, but -Werror turns it into an error and that's no good.

0 Kudos
HemanthKum_G_Intel
730 Views

Hi Eran,

Ok, this is related to project hierarchy. You are free to customize the openvino cmake. Just replicate the windows cmake branching to the non-windows one. Maybe it have a different flag, but you can give a try with a relevant flag.

# treating warnings as errors
if (WIN32)
    if (TREAT_WARNING_AS_ERROR)
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
    endif ()
    if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4275 /wd4267") #disable some warnings
    endif()
else()
    if (TREAT_WARNING_AS_ERROR)
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
    endif()
endif()

 

0 Kudos
Eran_L_Intel
Employee
730 Views

I did more than changing the CMake, I fixed the source code. :)

However, our users (this is open-source code) will not get a good experience if they come across this and should not be expected to fix it on their own.

In my humble opinion, OpenVINO source should: 1. Not use -Werror (which forces us to deal with these kinds of issues) and 2. Remove the semicolons in the .cpp, so as not to generate warnings. The other warnings (/wd4251, etc.) on Windows are also very annoying and I actually had to place '#pragma warning' directives to disable them.

Thanks and cheers!

0 Kudos
HemanthKum_G_Intel
730 Views

Hi Eran,

Thank you for the valuable feedback. It will be reported to OpenVINO development team.

0 Kudos
Reply